Can you do this in D?

Wes ffhighwind at hotmail.com
Thu Jul 26 05:12:37 PDT 2012


> I think it's a missing feature. But what are the use cases? In 
> Python it's easy to do, but it's not a common need.
True, I suppose. It just seems like the programmer could have 
access to some sort of associative array, where you could have 
multiple stored values per key sorted by scope.

> With their names and mixin() then maybe you able to do what you 
> look for.
So basically there's no easy way to make a prettyprint like:
foreach(field;__traits(allFields, myClass)) { str ~= field; }

> With the proposed __ctWrtiteln you are able to print things at 
> compile time to standard output. But there is no enough 
> introspection to know how much time it takes to compile part of 
> a program.
Assuming this is the same as #pragma (msg, ""). I just meant 
actually calling code that runs at compile time that isn't a 
static-ly defined constant.

> The operator overloading syntax is string-based, so adding new 
> operators is not too much hard. But I don't know what are the 
> advantages and disadvantages. The $ operator is used (in a 
> certain context) to denote the length of collections.
I'm not sure what you mean. Do you mean I can go edit the open 
source compiler and add in my own language feature? Or does the 
ability to add a $/@ operator already exist?



More information about the Digitalmars-d mailing list