Re: Generating unique identifiers at compile time

2022-06-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 June 2022 at 07:38:54 UTC, user1234 wrote: On Thursday, 9 June 2022 at 23:50:10 UTC, user1234 wrote: On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: [...] No, for now there if there are other ways they are as hacky as yours. The compiler usually uses a global counter to g

Re: Generating unique identifiers at compile time

2022-06-13 Thread user1234 via Digitalmars-d-learn
On Thursday, 9 June 2022 at 23:50:10 UTC, user1234 wrote: On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: [...] No, for now there if there are other ways they are as hacky as yours. The compiler usually uses a global counter to generate temporaries. There's [been attempts] to expose it

Re: Generating unique identifiers at compile time

2022-06-12 Thread JG via Digitalmars-d-learn
On Sunday, 12 June 2022 at 18:45:27 UTC, Paul Backus wrote: On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: [...] [...] [...] Here's a `gensym` implementation I came up with a while back: ```d enum gensym = q{"_gensym" ~ __traits(identifier, {})["__lambda".length .. $]}; // Works mul

Re: Generating unique identifiers at compile time

2022-06-12 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: In doing so I wanted to produce unique identifiers (something like gensym in racket.) I did this in a very hacky way: [...] Is there some way to ask the compiler for a unique name or a better way of achieving this? Here's a `gensym` implemen

Re: Generating unique identifiers at compile time

2022-06-12 Thread JG via Digitalmars-d-learn
On Friday, 10 June 2022 at 06:17:54 UTC, bauss wrote: On Thursday, 9 June 2022 at 23:50:10 UTC, user1234 wrote: There's [been attempts] to expose it, exactly so that users can generate unique names, but that did not found its path in the compiler. [been attempts]: https://github.com/dlang/d

Re: Generating unique identifiers at compile time

2022-06-09 Thread bauss via Digitalmars-d-learn
On Thursday, 9 June 2022 at 23:50:10 UTC, user1234 wrote: There's [been attempts] to expose it, exactly so that users can generate unique names, but that did not found its path in the compiler. [been attempts]: https://github.com/dlang/dmd/pull/10131 You can generate unique names actually

Re: Generating unique identifiers at compile time

2022-06-09 Thread user1234 via Digitalmars-d-learn
On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: Hi, As an experiment I have implemented the following kind of pattern matching (by parsing the part of the string before '='). ```d struct S { int x; int y; } struct T { int w; S s; } void main() { mixin(matchAssign(q{auto T(fir

Generating unique identifiers at compile time

2022-06-09 Thread JG via Digitalmars-d-learn
Hi, As an experiment I have implemented the following kind of pattern matching (by parsing the part of the string before '='). ```d struct S { int x; int y; } struct T { int w; S s; } void main() { mixin(matchAssign(q{auto T(first,S(second,third)) = T(1,S(2,3));})); first.wr