[debate] About D's pretension for homoiconicicity

Simen kjaeraas simen.kjaras at gmail.com
Thu Oct 21 09:15:00 PDT 2010


Justin Johansson <no at spam.com> wrote:

> The formal subject proposed for debate is
> "D's advanced meta-programming capabilities essentially
> makes it (D) as if it were a homoiconic language, and
> brings with it all the advantages of homoiconic languages."

Hardly true. While it may be possible to Greenspun together
a hacky attempt at homoiconicity in D, Doing so would bring
but a few of the benefits compared to a language designed
 from the beginning with homoiconicity in mind.

That said, some of the use cases for homoiconicity may be
covered by D's capabilities, and this may be closer to what
you intended by the above paragraph.

Certainly D does not allow one to execute arbitrary
strings as if they were D code (D does however allow the
execution of arbitrary strings). There certainly are ways
to do that, but such could be said for any language.

It would certainly be possible to create a system for
manipulating ASTs at compile time in D, be they generated
by library code or the compiler itself. Converting such
a representation to a mixin string should prove no big
challenge. However, even such a system would likely lack
the elegance of lisp's macros, and I find it unlikely it
would find much use. Another problem with this is that
it's useless at runtime, unless an interface to the
compiler is offered as a library for D. This has been
discussed numerous times, and I believe most on this list
agree it would a Good Thing™.

-- 
Simen


More information about the Digitalmars-d mailing list