What would a minimal subset of D look like?

Mike Franklin slavo5150 at yahoo.com
Sat Jun 22 11:07:13 UTC 2019


On Saturday, 22 June 2019 at 10:50:35 UTC, Ola Fosheim Grøstad 
wrote:

>> I'm quite convinced that if we added `opImplicitCast` to the 
>> language, we could implement `alias this` and multiple `alias 
>> this` in the language.  There was a recent discussion about 
>> that too: 
>> https://forum.dlang.org/post/ozdjozskgwqxfykijrsh@forum.dlang.org
>
> Hmm, yes, but if one is forced to resort to using string 
> concatenation in a macroish fashion then I think that would be 
> a sign of a missing language feature or that the meta 
> programming capabilities need improvement.

Yes, my implementation in that post was extremely poor, and 
that's being kind.  Adam's response was appropriate.  It was just 
an illustration, and I'm sure there are better ways to implement 
it, as Adam showed.  My point was that D has sufficient 
metaprogramming and introspection features to do it, and if it 
were implemented in the library it would be encapsulated from the 
user and would sit quietly in a dark corner of D's library.  Most 
people will just use it and never look at the implementation as 
long as it works.

> Although, perhaps the argument you are making is that "alias 
> this" is not really needed, but if you absolutely need it one 
> time, then it is possible?  Like an "escape-hatch"?

No, I would use it extensively to implement convenient 
composition and avoid inheritance.

Mike


More information about the Digitalmars-d mailing list