guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Please explain different macros


From: Marius Vollmer
Subject: Re: Please explain different macros
Date: 20 Apr 2001 18:21:56 +0200
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7

"Dale P. Smith" <address@hidden> writes:

> Could someone please explain (in plain english) the differences
> between the 3 different kinds of "native" macros that Guile
> supports.  As opposed to the system in r5rs?  We have acro, macro
> and mmacro.

Given the form

    (foo ...)

the following things happen when it is evaluated:

- when `foo' has been defined to be an `acro'

  The procedure used in the acro definition of `foo' is passed the
  form (and the current lexical environment) and whatever that
  procedure returns is the value of evaluating the form.

  You can thing of this a procedure that receives its argument in
  unevaluated form.

- when `foo' has been defined to be a `macro'

  The procedure used in the acro definition of `foo' is passed the
  form (and the current lexical environment) and whatever that
  procedure returns is again evaluated.  That is, the procedure should
  return a valid Scheme expression.

- when `foo' has been defined to be a `mmacro'

  The procedure used in the acro definition of `foo' is passed the
  form (and the current lexical environment) and whatever that
  procedure returns replaces the form in the original expression.
  Then evaluation starts over from the new form that has just been
  returned.

  The difference to a `macro' is that the expression returned by a
  `mmarco' procedure is remembered so that the next time the origignal
  form is evaluated, the expansion does not need to be done again.


If you do not have a very special reason to use one of the
`procedure->...' functions, you should avoid them.  Use `defmacro',
`define-macro' or `define-syntax' instead.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]