Mixin every entity
Basile B.
b2.temp at gmx.com
Wed Jul 24 20:17:21 UTC 2024
On Wednesday, 24 July 2024 at 11:57:35 UTC, Quirin Schroll wrote:
> Mixins can produce types, expressions, statements, and
> declarations. That is great, but it could be better.
>
> Why not allow mixin identifiers, storage classes, attributes,
> etc.?
>
> Contrived example:
> ```d
> struct mixin("C")
> {
> mixin("const"):
> void f(mixin("ref") int x) mixin("@safe") { }
> }
> ```
>
> There’s no good reason a whole entity must be written in a
> string literal with a “hole” to be filled by `format` just
> because its name is generated. Interpolated strings help, but
> are not fundamentally different.
There is a good reason for that, that is not what is explained in
one of the answer I can read. Mixins must introduce full
grammatical constructs, i.e an expression, a statement, or a
declaration, so that the content can be passed to the parser.
Also they cant interfere with a scope. There's a well known bug
(closed as of today), `mixin("private:")`.
More information about the dip.ideas
mailing list