[racket] Wikipedia article update
--- On Thu, 5/3/12, Hendrik Boom <hendrik at topoi.pooq.com> wrote:
> From: Hendrik Boom <hendrik at topoi.pooq.com>
> Subject: Re: [racket] Wikipedia article update
> To: users at racket-lang.org
> Date: Thursday, May 3, 2012, 8:51 PM
> On Thu, May 03, 2012 at 05:02:08PM
> -0700, John Clements wrote:
> >
> > and updated the Wikipedia page to reflect my better
> understanding. The text now reads:
> >
> > "The earliest Lisp macros took the form of FEXPRs,
> function-like operators whose inputs were not the values
> computed by the arguments but rather the syntactic forms of
> the arguments, and whose output were values to be used in
> the computation. In other words, FEXPRs were implemented at
> the same level as EVAL, and provided a window into the
> meta-evaluation layer. This was generally found to be a
> difficult model to reason about effectively [6].
> > An alternate, later facility was called DEFMACRO, a
> system that allowed programmers to specify source-to-source
> transformations that were applied before the program is
> run."
>
> FEXPRs were used to implement things like COND, QUOTE, and
> the like.
> It would be difficult to use macros instead of FEXPRs for
> these,
> unless they were built into the interpreter. And
> FEXPRs were the
> mechanism by which this was done.
>
FEXPRs are still used in Pico Lisp and NewLisp.
They are simply functions whose arguments aren't evaluated.
> (define-macro (foo x) x)
(lambda-macro (x) x)
> (foo (* 2 3 4))
(* 2 3 4)
> (list? (foo (* 2 3 4)))
true
> (define-macro (bar x) (println x) (+ x 1000))
(lambda-macro (x) (println x) (+ x 1000))
> (bar (* 2 3))
(* 2 3)
ERR: value expected in function + : x
called from user defined function bar
> (define-macro (bar x) (+ (eval x) 1000))
(lambda-macro (x) (+ (eval x) 1000))
> (bar (* 2 3))
1006