Mixin every entity

Nick Treleaven nick at geany.org
Wed Jul 24 17:41:58 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.?

Just to mention, any new non-trivial feature needs compelling 
use-cases.
> Contrived example:
> ```d
> struct mixin("C")
> {
> mixin("const"):
>     void f(mixin("ref") int x) mixin("@safe") { }
> }
> ```

Perhaps being able to alias attributes would be nicer, for 
metaprogramming.

> 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.

Mixin identifiers would be useful:
https://forum.dlang.org/post/aznmkielsozvfgrzehoc@forum.dlang.org

Generally if you could mixin anything, that would probably make 
parsing much more complicated for tools.


More information about the dip.ideas mailing list