Postfix type notation - readability and parsing?
Paul Backus
snarwin at gmail.com
Mon Mar 11 16:28:16 UTC 2019
On Monday, 11 March 2019 at 08:13:04 UTC, Simen Kjærås wrote:
> On Saturday, 9 March 2019 at 20:50:37 UTC, Paul Backus wrote:
>
>> The only issue with using __LINE__ is that it requires gensym
>> to be evaluated in the same scope as the one the variable is
>> being declared in.
>
> There are other issues:
>
> string gensym(size_t id = __LINE__) {
> return format("_gensym_%d", id);
> }
>
> static assert(gensym() == gensym()); // We don't want this to
> pass.
>
> unittest {
> string[2] s;
> static foreach (i; 0..2) {
> s[i] = gensym;
> }
> assert(s[0] == s[1]); // Nor this.
> }
>
> The first would be fixed by having __COL__ (being the column of
> the line on which gensym is being called). However, that does
> nothing for the second case.
>
> --
> Simen
These are definitely annoying, but you can at least get around
them by writing stuff like `gensym(i)`, as suggested in H. S.
Teoh's post.
More information about the Digitalmars-d
mailing list