[Issue 2698] Syntax to parse an identifier from a string, instead of mixin()
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 31 12:52:38 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=2698
--- Comment #8 from Nick Treleaven <nick at geany.org> ---
(In reply to Nick Treleaven from comment #3)
> I prefer the __identifier(ident) syntax than mixin(ident)
> ...
> 3. it doesn't refine the idea of mixin to more than just
> expressions/statements (i.e. code, not an identifier).
Since then, string mixins can be used in place of a type:
https://dlang.org/spec/type.html#mixin_types
So it would be consistent to allow mixin identifiers too.
They can also now take multiple arguments which are converted to strings and
concatenated. I think these changes make using `mixin` a better choice for
syntax.
static foreach(n; [1,2,3]) {
int mixin("foo", n) = n;
}
assert(foo1 == 1);
(In reply to Nick Treleaven from comment #7)
> The point of this feature is to avoid writing the whole
> symbol inside a string just because you need an identifier
> name to be mixed in.
The whole *declaration* currently has to be in a string, often just because of
the identifier for the declaration.
--
More information about the Digitalmars-d-bugs
mailing list