Interlisp / medley

The main repo for the Medley Interlisp project. Wiki, Issues are here. Other repositories include maiko (the VM implementation) and Interlisp.github.io (web site sources)
https://Interlisp.org
MIT License
375 stars 19 forks source link

Relation between Common Lisp and Interlisp macros needs better explanation #1094

Open masinter opened 1 year ago

masinter commented 1 year ago

Originally posted by @pamoroso in https://github.com/Interlisp/Interlisp.github.io/issues/70#issuecomment-1455025657

Moving to a "documentation" issue in the Medley repo.

Interlisp does not have a special function for defining macros. Macros are defined by placing their definition on the property list of the symbol.

Didn't Interlisp eventually add support for DEFMACRO?

I started to edit this text, but had trouble; I thought it deserved a separate issue and some thought. The relationship between Common Lisp and Interlisp is often described in terms of "In Interlisp XXX, while in Common Lisp YYYY", as it was when you had to choose one or the other for your entire application. In Medley, though, you can use both intermixed to a large degree. The explanation of exactly when the differences matter is complex.

For macros, there are Interlisp-style macros (defined by putting an IL:MACRO property on the litatom/symbol) and Common Lisp macros (defined by DEFMACRO, which is the same (EQ 'CL:MACRO 'IL:MACRO).) CL:EVAL and IL:EVAL differ in how they treat variable scoping, as do CL:LAMBDA and IL:LAMBDA. There are two compilers but CL:COMPILE-FILE and CL:COMPILE will compile both.

The introductory document doesn't seem like the place to elaborate those distinctions, and for the casual user it's probably better to keep things simple.

rmkaplan commented 1 year ago

But note that DEFMACRO (among other things, like lexial scoping) is broken wrt the LCOM compiler. The filemap is screwed up if you have a DEFMACRO, and a recompile under CLEANUP simply bombs out. You think your file has been compiled, but it hasn’t. You have to always explicitly do TCOMPL

There is probably an issue on this, a bug that needs to be fixed.

On Mar 5, 2023, at 8:55 AM, Larry Masinter @.***> wrote:

Originally posted by @pamoroso https://github.com/pamoroso in Interlisp/Interlisp.github.io#70 (comment) https://github.com/Interlisp/Interlisp.github.io/pull/70#issuecomment-1455025657 Moving to a "documentation" issue in the Medley repo.

Interlisp does not have a special function for defining macros. Macros are defined by placing their definition on the property list of the symbol.

Didn't Interlisp eventually add support for DEFMACRO https://groups.google.com/g/interlisp/c/ALbf30uMD98/m/fHFHv2fnBAAJ?

I started to edit this text, but had trouble; I thought it deserved a separate issue and some thought. The relationship between Common Lisp and Interlisp is often described in terms of "In Interlisp XXX, while in Common Lisp YYYY", as it was when you had to choose one or the other for your entire application. In Medley, though, you can use both intermixed to a large degree. The explanation of exactly when the differences matter is complex.

For macros, there are Interlisp-style macros (defined by putting an IL:MACRO property on the litatom/symbol) and Common Lisp macros (defined by DEFMACRO, which is the same (EQ 'CL:MACRO 'IL:MACRO).) CL:EVAL and IL:EVAL differ in how they treat variable scoping, as do CL:LAMBDA and IL:LAMBDA. There are two compilers but CL:COMPILE-FILE and CL:COMPILE will compile both.

The introductory document doesn't seem like the place to elaborate those distinctions, and for the casual user it's probably better to keep things simple.

— Reply to this email directly, view it on GitHub https://github.com/Interlisp/medley/issues/1094, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSTUJLLXCHRHYWBA6HZRF3W2TARVANCNFSM6AAAAAAVQISLAU. You are receiving this because you are subscribed to this thread.

pamoroso commented 1 year ago

My Stringscope program defines a macro but CLEANUP seems to work fine, i.e. it compiles with no errors.

rmkaplan commented 1 year ago

Which compiler, LCOM or DFASL?

Is the DEFMACRO at the end, after all the functions?

On Mar 5, 2023, at 9:35 AM, Paolo Amoroso @.***> wrote:

My Stringscope program defines a macro but CLEANUP seems to work fine, i.e. it compiles with no errors.

— Reply to this email directly, view it on GitHub https://github.com/Interlisp/medley/issues/1094#issuecomment-1455154018, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSTUJK47E2UJAJYQOXFJETW2TFEZANCNFSM6AAAAAAVQISLAU. You are receiving this because you commented.

pamoroso commented 1 year ago

The LCOM compiler. The source of the Stringscope version I'm referring to is here and the DEFMACRO is the last form before (DECLARE%: DONTCOPY ...).

rmkaplan commented 1 year ago

What is the value of CLEANUPOPTIONS?

On Mar 5, 2023, at 10:27 AM, Paolo Amoroso @.***> wrote:

The LCOM compiler. The source of the Stringscope version I'm referring to is here https://groups.google.com/g/interlisp/c/ZwtXaSa7VzE/m/t9dJFL4jDwAJ and the DEFMACRO is the last form before (DECLARE%: DONTCOPY ...).

— Reply to this email directly, view it on GitHub https://github.com/Interlisp/medley/issues/1094#issuecomment-1455166579, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSTUJNED5Z5WUEIWJMN4JLW2TLJLANCNFSM6AAAAAAVQISLAU. You are receiving this because you commented.

pamoroso commented 1 year ago

The value of CLEANUPOPTIONS is (RC).

masinter commented 1 year ago

perhaps it is better to say that TCOMPL / BCOMPL (which produce LCOMs) don't know how to compile DEFUNs and DEFMACROs, while CL:COMPILE-FILE (which produces DFASL files) does. Anyway, if there's a problem with a test case we could try to fix it. If the problem is LOADFNS not working on DFASL files, I think that could be fixed/