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

Re: are dylan macros Turing-complete?



neelk@alum.mit.edu (Neelakantan Krishnaswami) writes:

> Dylan macros are definitely Turing complete. Here's an (untested)
> lambda calculus implementation as a macro:

Okay, very cool.  So the generated code would be your answer.

One related question; the Dylan macro system has no standard way to
perform arbitrary computation in a way that could usefully affect the
compiler process, correct?  Stated another way, all you can do is
generate Dylan code, not run it.

An example of a "useful" way of affecting the compiler process would
be to change an in-memory variable, or perform I/O.  For this purpose,
looping infinitely is not useful.

I do note that in the Gwydion Dylan implementation, some macros (such
as :=), seem to call functions in the compiler to compute their
expansion:

define macro \:=
    { \:= (?place:expression, ?value:expression) }
      => make-assignment({ ?place }, { ?value })
end;

This is not a standard part of the Dylan macro system, correct?  My
reading of the "Templates" section of the DRM seems to suggest so,
but I'm not completely sure.

> Try this instead:
> 
>   define macro loop
>     {loop()} => {loop()}
>   end macro;

Aah.  Of course.  If the macro expansion can be recursive, then you
have an easy way to loop infinitely.  Thanks.