[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: are dylan macros Turing-complete?
In article <joswig-C01149.02090211052002@news.fu-berlin.de>,
Rainer Joswig <joswig@lispmachine.de> wrote:
> In article <bruce-E18C63.19354009052002@copper.ipg.tsnz.net>,
> Bruce Hoult <bruce@hoult.org> wrote:
>
> > My own philosophy on the use of macros is that they are not for doing
> > computation, but merely for rearranging the surface syntax so that the
> > programmer can write something in syntax convenient to their application
> > domain, and that is transformed into concrete code that implements their
> > abstraction. If this process requires optimization then that should
> > take place in the compiler proper.
>
> I see some uses of macros.
>
> For non-top-level macros I often want to manipulate the
> identifier names. This is for example not possible
> with Scheme-Macros. They are only supporting little
> rewriting of list structures - but not for example
> of names. Example (pardon the prefix syntax):
>
> (with-foo "bar" (baz)) -> (let ((foo-bar ...)) ... (baz))
>
> In Scheme I can't compute the foo-bar symbol via
> macros.
You can in Dylan.
> Another thing that's important (especially for top-level
> macros) is that Macros can generate compile-time side-effects,
> which are controlled by the programmer.
>
> Example
>
> (define-function foo (bar) ...)
>
> Expands to (defun foo (bar) ...)
That's easy in Dylan.
> and could have, for example, the side effect to enter the
> function into a database at compile time. This comes very
> handy, for example, when you develop new (sub-)languages
> on top of CL and want to do some programming environment
> stuff on your own. This is also interesting when
> you want to lookup definitions at compile-time from
> a database (done with FFIs, foreign function interfaces).
> Etc.
You can't do these things at compile-time in Dylan. You can however do
them at program load time.
There is also a design for adding procedural macros pretty seamlessly to
the current pattern replacement macros. See:
http://www.ai.mit.edu/~jrb/Projects/dexprs.pdf
-- Bruce