Can you do this in D?

Wes ffhighwind at hotmail.com
Thu Jul 26 04:20:34 PDT 2012


Can you do this in D? If not then what other language?

1. Can you get a list of all classes and variables in the current
scope e.g. __traits()?

2. Can you statically iterate over every field of a class?
It seems like the only returns are string lists from __traits().
I basically am interested in being able to generate a
PrettyPrint/Serializable/Hash template without passing in every
single field.

3. Is there any way of executing code or programs during compile
time?
I've seen an example of CTFE (Compile Time Function Evaluation),
although I'm unsure if this works for stuff like classes.
However, I am considering more advanced execution (not constants)
such as printing to a file during compiling for stuff like how
long compiling a certain function/template takes.

4. Is there anything like Go/Erlang channels? (synchronous queues)
I assume that synchronized blocks with a shared global dynamic
array would be the solution without the special syntax sugar?

5. Why not support other operators like $, #, and @?
This is more of a rhetorical... as I know the language doesn't
need them, nor would I know if they would be binary/unary
prefix/etc or the precedence... although they would be nice to
have. Specifically I'd like $prefix to be stringification.


More information about the Digitalmars-d mailing list