Metaprogramming
Thomas Lindgren
thomasl_erlang@REDACTED
Wed Aug 23 20:22:30 CEST 2006
--- Ryan Rawson <ryanobjc@REDACTED> wrote:
> Meta functions? like as in scheme:
>
> (define (lambda (x y)
> (lambda (x)
> (* x y) ) ) )
>
> ?
>
> I think Erlang has a very weak meta programming
> ability. You can't
> define your "meta functions" in the language - they
> are strings.
Erlang (or rather, the Erlang/OTP implementation) has
a well-defined format for parse trees and the compiler
can invoke 'parse transforms' on these which examine
and rewrite the functions and forms quite flexibly.
This in itself takes you pretty far. There is a
compiler, a code loader and an interpreter too to take
your generated program and execute it.
Erlang doesn't go as far as Lisp, which also has full
macros, an easier correspondence between program and
data, more sophisticated operations on syntax trees,
etc etc. But if Lisp gets five stars, then Erlang (and
a number of similar languages) would get three, maybe
four stars in my book. (Prolog is a bit better than
Erlang on this scale, because Prolog programs and data
correspond better*, but still not quite as good as
Lisp.)
So it pains me to hear "very weak metaprogramming". I
think "very weak metaprogramming" is understating the
case greatly. "Very weak" is something like C, where
there is essentially no standard support for it.
Best,
Thomas
* for the technically curious, such a correspondence
avoids or mitigates the "double encoding problem"
which is a practical metaprogramming difficulty.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the erlang-questions
mailing list