feature request: __ARGS__ for logging (cf __FILE__, __LINE__, __FUNC___)
bearophile
bearophileHUGS at lycos.com
Sun Feb 3 12:53:06 PST 2013
Dejan Lekic:
> Jacob, I humbly believe this should be a new DIP ...
I agree.
> This proposal, if realised, would bring very useful feature to
> D...
The Scala-style macros, with enough reflection (plus maybe
pattern matching implemented with the macro themselves) are able
to expand the flexibility of D.
But macros have some costs. They add complexity to the language,
and make code that uses macros less easy to understand. The
almost only good place to use macros is in well known and well
debugged library code, standard code, like in Phobos.
Most D programmers are not going to be able to use macros. If you
add macros you create even more the levels of programmers they
talk about in Scala:
http://www.scala-lang.org/node/8610
One of the most powerful and useful features of CommonLisp (and
similar languages) are macros. They add power to the language,
but flexibility itself has a high cost. It makes hard for the
programmer A to understand and use code written by programmer B.
It goes against some of the things that foster the creation of an
ecology of reusable modules as in Python and Perl. Too much
flexibility is dangerous. Even Scala is risking that with its
macros. Lot of programming situations where today Java is used
aren't going to use Scala and its macros. Macros are both part of
the power of Lisp and one of the causes of its "failure".
So it's a matter of balancing things: are macros going to give to
D more than the (high) price they ask for? I like AST macros, but
I don't know the answer.
Bye,
bearophile
More information about the Digitalmars-d
mailing list