Re: Lisp's QUOTE and Mathematica's "Hold"



Peter Seibel wrote:
> Then you should check out Lisp.

:-)

> Macros are interesting in this context
> insofar as they are an *example* of a part of Lisp that depends on the
> ability to write code in Lisp that does AST->AST transformations.[1]

But Lisp functions can also do AST -> AST transformations using the built-in
AST type, available via QUOTE but you never want to EVAL them. Is that
about right?

> But ultimately macros are for producing Lisp code. If you just want
> to manipulate arbitrary ASTs and/or if you ultimately want to produce
> some other form of output (such as code in another language or machine
> code or typeset math) then these Lisp features are what you should be
> looking at:
> ...

I'll check them out, thanks.

> and ... wait for it ...
>
> - QUOTE.

In ML you'd define your own AST type and use pattern matching to manipulate
values of that type. Am I right in thinking that, in Lisp, you would use
Quote to build a Lisp-like AST instead of defining your own AST type?

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com
.



Relevant Pages

  • Re: Extol virtues of Lisp, but then use Python?
    ... Some Lisp interpreters execute the AST forms directly but the standard ... I say in principle because the Python community would ... at the mercy of the compiler developer. ...
    (comp.lang.scheme)
  • Re: Extol virtues of Lisp, but then use Python?
    ... in principle work like a Lisp macro. ... I say in principle because the Python community would ... the format of the AST could change between Python ... But you said "the standard does not require the AST to be ...
    (comp.lang.scheme)
  • Re: Extol virtues of Lisp, but then use Python?
    ... standard - a specifically formed CONS tree is defined for each ... Some Lisp interpreters execute the AST forms directly but the standard ... I say in principle because the Python community would ...
    (comp.lang.scheme)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... >> Then you should check out Lisp. ... > But Lisp functions can also do AST -> AST transformations using the ... > built-in AST type, available via QUOTE but you never want to EVAL ... >> want to manipulate arbitrary ASTs and/or if you ultimately want to ...
    (comp.lang.lisp)
  • Re: Extol virtues of Lisp, but then use Python?
    ... in principle work like a Lisp macro. ... I say in principle because the Python community would ... the format of the AST could change between Python ... some of this functionality can be had in any environment ...
    (comp.lang.scheme)