How can I dump an expression into log and execute it

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 14 02:55:43 PDT 2014


On Sunday, 13 July 2014 at 20:54:27 UTC, Ary Borenszweig wrote:
>> AST reflection + string mixins can do anything that AST macros 
>> can do -
>> assuming one does not want to allow transparent macros 
>> (without explicit
>> mixin/macro keyword at call site) which is a terrible idea in 
>> my opinion
>> anyway.
>
> Why?

Good language encourages code base with small "surprise factor". 
That means that by looking at a single line of code you can may 
quick safe assumptions about it. Limiting operator overloading, 
advertising pure functions, banning silent macros - all it helps 
this goal. Explicit "mixin" keyword warns you : "Here be dragons! 
Exceptional stuff may happen, pay attention".

Silent macros easily break any basic language assumptions and 
thus are bad in that regard.

I must admit D is far from perfect in that regard because 
operator overloading is still not limited enough and optional 
parens / unconstrained properties may wreck their own havoc. But 
this is hardly an excuse for introducing new features with even 
more surprise potential.


More information about the Digitalmars-d mailing list