digitalmars.D.announce - Bolts 0.4 meta programming library
- aliak (40/40) Aug 02 2018 Hi, just a release of a meta programming library
- John Colvin (10/50) Aug 02 2018 This looks cool. Lots of things that lots of people have
- John Colvin (7/70) Aug 02 2018 woops, pressed send too early:
- aliak (14/32) Aug 02 2018 Thanks! And yes, totally aware of that. I have tried to link to
- Patrick Schluter (5/19) Aug 02 2018 ’tis like in "’Tis the season to be jolly."
- aliak (7/32) Aug 02 2018 Hehe, I went with iz, and now the docs for iz reads:
- Patrick Schluter (2/10) Aug 02 2018 Isn't "doth" just an antiquated orthography of "does"?
Hi, just a release of a meta programming library (https://bolts.dub.pm) that has utilities that I use in personal projects, and that I find in phobos, and or in the forums. A notable difference is that functions here try to operate on any compile time entities if they can be resolved. I.e.: int i; void g0(int) {} struct S { void g1(int) {} } alias g2 = (int a) => a; static assert(isFunctionOver!(g0, int)); static assert(isFunctionOver!(S.g1, 3)); static assert(isFunctionOver!(g2, i)); And there's a "doth" super template that tries to contain most things under what I feel is a nicer api ("is" was taken, so i looked to Shakespearian gibberish :p) and also allows for easier use with meta functions: E.g.: int *pi = null; static assert( doth!3.of!int); static assert(!doth!pi.nullable); static assert( doth!((a, b, c, d) => a).functionOver!(int, int, int, int)); int i; import std.meta: allSatisfy; static assert(allSatisfy!(doth!int.of, 3, 4, int, i)); Here's an example of a gem adapted from inside the forms/phobos sources as well: alias a = AliasPack!(1, 2, 3); alias b = AliasPack!(4, 5, 6); alias c = AliasPack!(7, 8, 9); alias d = staticZip!(a, b, c); static assert(d.length == 3); static assert(d.Unpack[0].equals!(1, 4, 7)); static assert(d.Unpack[1].equals!(2, 5, 8)); static assert(d.Unpack[2].equals!(3, 6, 9)) static assert(AliasPack!(d.UnpackDeep).equals!(1, 4, 7, 2, 5, 8, 3, 6, 9)); Cheers, - Ali
Aug 02 2018
On Thursday, 2 August 2018 at 07:47:19 UTC, aliak wrote:Hi, just a release of a meta programming library (https://bolts.dub.pm) that has utilities that I use in personal projects, and that I find in phobos, and or in the forums. A notable difference is that functions here try to operate on any compile time entities if they can be resolved. I.e.: int i; void g0(int) {} struct S { void g1(int) {} } alias g2 = (int a) => a; static assert(isFunctionOver!(g0, int)); static assert(isFunctionOver!(S.g1, 3)); static assert(isFunctionOver!(g2, i)); And there's a "doth" super template that tries to contain most things under what I feel is a nicer api ("is" was taken, so i looked to Shakespearian gibberish :p) and also allows for easier use with meta functions: E.g.: int *pi = null; static assert( doth!3.of!int); static assert(!doth!pi.nullable); static assert( doth!((a, b, c, d) => a).functionOver!(int, int, int, int)); int i; import std.meta: allSatisfy; static assert(allSatisfy!(doth!int.of, 3, 4, int, i)); Here's an example of a gem adapted from inside the forms/phobos sources as well: alias a = AliasPack!(1, 2, 3); alias b = AliasPack!(4, 5, 6); alias c = AliasPack!(7, 8, 9); alias d = staticZip!(a, b, c); static assert(d.length == 3); static assert(d.Unpack[0].equals!(1, 4, 7)); static assert(d.Unpack[1].equals!(2, 5, 8)); static assert(d.Unpack[2].equals!(3, 6, 9)) static assert(AliasPack!(d.UnpackDeep).equals!(1, 4, 7, 2, 5, 8, 3, 6, 9)); Cheers, - AliThis looks cool. Lots of things that lots of people have reimplemented lots of times over the years, but all in one place and documented. 2 points: 1) Are you aware of this: https://github.com/dlang/phobos/blob/master/std/meta.d ? I think if a bunch of good motivating examples are given, making this public would be possible. Then everyone would be using the same one and your library would truly just be utilities.
Aug 02 2018
On Thursday, 2 August 2018 at 08:40:55 UTC, John Colvin wrote:On Thursday, 2 August 2018 at 07:47:19 UTC, aliak wrote:woops, pressed send too early: 2) I don't think "doth" is synonymous with "is" how you're using it. "doth" is for doing, e.g. "Methinks he doth protest too much" or "This code doth stink" is OK "Green doth a colour" or "strstr doth a function" is not OK.Hi, just a release of a meta programming library (https://bolts.dub.pm) that has utilities that I use in personal projects, and that I find in phobos, and or in the forums. A notable difference is that functions here try to operate on any compile time entities if they can be resolved. I.e.: int i; void g0(int) {} struct S { void g1(int) {} } alias g2 = (int a) => a; static assert(isFunctionOver!(g0, int)); static assert(isFunctionOver!(S.g1, 3)); static assert(isFunctionOver!(g2, i)); And there's a "doth" super template that tries to contain most things under what I feel is a nicer api ("is" was taken, so i looked to Shakespearian gibberish :p) and also allows for easier use with meta functions: E.g.: int *pi = null; static assert( doth!3.of!int); static assert(!doth!pi.nullable); static assert( doth!((a, b, c, d) => a).functionOver!(int, int, int, int)); int i; import std.meta: allSatisfy; static assert(allSatisfy!(doth!int.of, 3, 4, int, i)); Here's an example of a gem adapted from inside the forms/phobos sources as well: alias a = AliasPack!(1, 2, 3); alias b = AliasPack!(4, 5, 6); alias c = AliasPack!(7, 8, 9); alias d = staticZip!(a, b, c); static assert(d.length == 3); static assert(d.Unpack[0].equals!(1, 4, 7)); static assert(d.Unpack[1].equals!(2, 5, 8)); static assert(d.Unpack[2].equals!(3, 6, 9)) static assert(AliasPack!(d.UnpackDeep).equals!(1, 4, 7, 2, 5, 8, 3, 6, 9)); Cheers, - AliThis looks cool. Lots of things that lots of people have reimplemented lots of times over the years, but all in one place and documented. 2 points: 1) Are you aware of this: https://github.com/dlang/phobos/blob/master/std/meta.d ? I think if a bunch of good motivating examples are given, making this public would be possible. Then everyone would be using the same one and your library would truly just be utilities.
Aug 02 2018
On Thursday, 2 August 2018 at 08:45:33 UTC, John Colvin wrote:On Thursday, 2 August 2018 at 08:40:55 UTC, John Colvin wrote:Thanks! And yes, totally aware of that. I have tried to link to relevant forum posts and will try to add more as I go along to where the usages were concocted. So I guess those could be the motivations? But it'd also be nice to just use it for a while and get feedback and experience with the names/APIs/functionalities/etc before adding it to std.meta. Though being in std would be ideal of course.This looks cool. Lots of things that lots of people have reimplemented lots of times over the years, but all in one place and documented. 2 points: 1) Are you aware of this: https://github.com/dlang/phobos/blob/master/std/meta.d ? I think if a bunch of good motivating examples are given, making this public would be possible. Then everyone would be using the same one and your library would truly just be utilities.woops, pressed send too early: 2) I don't think "doth" is synonymous with "is" how you're using it. "doth" is for doing, e.g. "Methinks he doth protest too much" or "This code doth stink" is OK "Green doth a colour" or "strstr doth a function" is not OK.Dammit! You're right! Thank you for pointing that out. Art! It's Art! ... or maybe i can use a hipster "is" ... i.e. "iz" :p Cheers, - Ali
Aug 02 2018
On Thursday, 2 August 2018 at 10:31:02 UTC, aliak wrote:On Thursday, 2 August 2018 at 08:45:33 UTC, John Colvin wrote:’tis like in "’Tis the season to be jolly." https://en.wiktionary.org/wiki/'tis Ok, Unicode (’ U+2019) in a symbol is not nice but works normally in D. :-)Thanks! And yes, totally aware of that. I have tried to link to relevant forum posts and will try to add more as I go along to where the usages were concocted. So I guess those could be the motivations? But it'd also be nice to just use it for a while and get feedback and experience with the names/APIs/functionalities/etc before adding it to std.meta. Though being in std would be ideal of course.[...][...]Dammit! You're right! Thank you for pointing that out. Art! It's Art! ... or maybe i can use a hipster "is" ... i.e. "iz" :p
Aug 02 2018
On Thursday, 2 August 2018 at 12:06:16 UTC, Patrick Schluter wrote:On Thursday, 2 August 2018 at 10:31:02 UTC, aliak wrote:Hehe, I went with iz, and now the docs for iz reads: "Iz is is - reason for choosing iz is because is is a keyword" :-D Are you sure about being able to use U+2019? I get: Error: character 0x2019 is not a valid tokenOn Thursday, 2 August 2018 at 08:45:33 UTC, John Colvin wrote:’tis like in "’Tis the season to be jolly." https://en.wiktionary.org/wiki/'tis Ok, Unicode (’ U+2019) in a symbol is not nice but works normally in D. :-)Thanks! And yes, totally aware of that. I have tried to link to relevant forum posts and will try to add more as I go along to where the usages were concocted. So I guess those could be the motivations? But it'd also be nice to just use it for a while and get feedback and experience with the names/APIs/functionalities/etc before adding it to std.meta. Though being in std would be ideal of course.[...][...]Dammit! You're right! Thank you for pointing that out. Art! It's Art! ... or maybe i can use a hipster "is" ... i.e. "iz" :p
Aug 02 2018
On Thursday, 2 August 2018 at 08:45:33 UTC, John Colvin wrote:On Thursday, 2 August 2018 at 08:40:55 UTC, John Colvin wrote:Isn't "doth" just an antiquated orthography of "does"?[...]woops, pressed send too early: 2) I don't think "doth" is synonymous with "is" how you're using it. "doth" is for doing, e.g. "Methinks he doth protest too much" or "This code doth stink" is OK "Green doth a colour" or "strstr doth a function" is not OK.
Aug 02 2018