Re: Python gets macros - now XML does too

From: Frank Buss (fb_at_frank-buss.de)
Date: 01/09/05


Date: Sun, 9 Jan 2005 00:57:28 +0000 (UTC)

Manuel Lemos <mlemos@acm.org> wrote:

> What is more interesting about the metaprogramming capabilities
> provided by MetaL is not metaprogramming features of level 0 (macro
> expansion) or even level 1 (generate code in other languages).
>
> The real power comes from level 2 metaprogramming features and
> eventually beyhond. Level 2 means that you write a code specification
> in an high level syntax. That that specification is translated into
> MetaL level 1/level 0 XML source code, which gets translated to the
> final target language of choice. Currently PHP, Java, and Perl are
> supported but it could be also LISP.

What you called level 2 metaprogramming is possible in Lisp, too. But as
far as I understand, you have to implement the expansion code in PHP for
your MetaL system. First a high-level description in XML, then
transforming it with a MetaL PHP module to a lower level XML description
and then transforming it again to Java or PHP with another MetaL PHP
module. This limits the things you can do or makes it too cumbersome. In
Lisp you use Lisp for transforming a macro to a lower level and the macro
code itself can use macros to help writing the macros easier, or you
could use the transformed macros for transforming other things (for
example you could implement the MetaL system with Lisp macros, which then
are used to translate XML to PHP, Lisp or Java).

Sometimes it might be necessary to use PHP or Java, for example if the
customer wants it, but your MetaL system shows, that PHP and Java are too
limited to use it without any external preprocessor, if you don't want to
write redundant code. This is ok, but in Lisp you write anything in Lisp;
you don't need to switch between different programming languages or
representations, and while writing your Lisp program, you enhance the
language itself to remove any redundant code.

-- 
Frank Buß, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de


Relevant Pages

  • Re: Python gets macros - now XML does too
    ... In Lisp, with macro expansion you can do arbitrary ... > domain-specific language as you describe. ... LISP macros to generate code in another language, say PHP, Java, Perl, ... Actually my main concern right now is PHP. ...
    (comp.lang.lisp)
  • Re: Paul Grahams teaching style is bad
    ... > It's surprisingly hard to explain what macros can do and why they are ... get to use as much lisp at work as I would like. ... "Macros allow me to easily create a specialized language, ... for PHP, he said that it was easy to do what Graham describes in PHP, ...
    (comp.lang.lisp)
  • Re: New book about Common Lisp: Let Over Lambda
    ... I have read every lisp book I've been able to get my hands on ... Lisp macros are not given nearly enough ... I personally consider Let Over Lambda to be an unofficial sequel ... integral parts of the language. ...
    (comp.lang.lisp)
  • Re: LISPPA
    ... > which describes the unification algorithm in Scheme. ... But let's get back to why I think lisp is superior ... optimization macros or reader ... cases where a running program cannot continue running, ...
    (comp.lang.lisp)
  • Re: Macro functionality at runtime?
    ... we don't know what the subtree is yet. ... "Returns a list of tokens matched to subtree. ... > be optimized out by the lisp compiler. ... >> If we have first class macros, ...
    (comp.lang.lisp)