Is metaprogramming useful?

Steve Horne stephenwantshornenospam100 at aol.com
Wed Nov 29 10:52:45 PST 2006


On Wed, 29 Nov 2006 11:47:10 -0500, Brad Anderson <brad at dsource.org>
wrote:

>I don't think this is the primary reason.  As mentioned before, syntax is a
>part of it, but so is the total power given to the programmer.  This power
>leads to a lack of standard or cohesive libs, b/c it's so easy to make it
>exactly the way you want it.  I imagine that if some of the D power users
>wrapped themselves in Lisp for a while, they'd be able to do for themselves
>what they beg Walter to do for them in D.

Not really.

There are things you just can't do with Scheme macros. Associativity
and precedence, for instance. This means that if you want to do these
things, you have to go the Von Neumann route - treat code as data and
manipulate it at compile time using Scheme functions.

That means you have to deal with parsing to ASTs, manipulating ASTs,
and back-end code generation. In short, you have to design a language
and write a compiler. And you have to do it without the benefit of
those high level tools, since you haven't written them yet - the
bootstrap thing.

You can get Scheme libraries for parsing and so on, so you're not
quite working from scratch, but you are working from a level that's
not substantially different than using Yacc and C. Except, of course,
that you've already got some of those higher level tools in C, and if
you need something higher level than that you could always use C++ or
some other language that has parsing tools available for it.

I shouldn't need to point out that designing a language and writing a
compiler from scratch isn't everyones favorite passtime.

Having a standard one as part of the library, maybe with support for
extending the dialect it provides - that sounds promissing. And while
Lisp implemented in D (as in dLisp) is a good thing if you have the
need, the way to make me really sit up and take notice is to show me D
implemented in Scheme.

-- 
Remove 'wants' and 'nospam' from e-mail.



More information about the Digitalmars-d mailing list