EXPANDMACRO

22 views
Skip to first unread message

Paolo Amoroso

unread,
Feb 17, 2023, 3:27:34 PM2/17/23
to Medley Interlisp Users/Interest
Consider this Interlisp macro:

(DEFMACRO WHEN (CONDITION &BODY BODY)
  `(if ,CONDITION then ,@BODY))


I would expect this call to EXPANDMACRO:

(EXPANDMACRO '(WHEN T (PRINT "TRUE")))

to work like CL:MACROEXPAND-1 and yield:

(if T then (PRINT "TRUE"))

Instead the above MACROEXPAND yields the same form received as input:

(WHEN T (PRINT "TRUE"))

Am I misunderstanding what EXPANDMACRO is supposed to do? Does it work like CL:MACROEXPAND? Does Interlisp have something similar to CL:MACROEXPAND-1 that does only one expansion step?

--

Nick Briggs

unread,
Feb 17, 2023, 4:28:05 PM2/17/23
to Paolo Amoroso, Medley Interlisp Users/Interest
DEFMACRO is a Common Lisp macro definer… even if you’re defining an Interlisp package symbol with it.  EXPANDMACRO is an Interlisp MACRO expander.  Don’t try to  mix them.


--
https://Interlisp.org for more details
---
You received this message because you are subscribed to the Google Groups "Medley Interlisp Users/Interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interlisp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/interlisp/CAGi1hzs2VOQfoFsGGXUbVAGC2G3ngwoZ2-0x3QC0QEUPeNe5YQ%40mail.gmail.com.

Paolo Amoroso

unread,
Feb 17, 2023, 4:37:28 PM2/17/23
to Nick Briggs, Medley Interlisp Users/Interest
On Fri, Feb 17, 2023 at 10:28 PM Nick Briggs <nicholas...@gmail.com> wrote:
DEFMACRO is a Common Lisp macro definer… even if you’re defining an Interlisp package symbol with it.  EXPANDMACRO is an Interlisp MACRO expander.  Don’t try to  mix them.

Thanks, reading this note on page 140 of the IRM PDF gave me the impression there was a IL:DEFMACRO in addition to CL:DEFMACRO:

Note: Like the function DEFMACRO in Common Lisp, this function currently removes any function definition for NAME.

On the same page, DEFMACRO is described with no other explicit reference to Common Lisp or packages.

Nick Briggs

unread,
Feb 17, 2023, 4:55:43 PM2/17/23
to Paolo Amoroso, Medley Interlisp Users/Interest
Also note that WHEN is already a CLISP word, so unclear to me which definition would get precedence anyway.

See medley/docs/medley-irm/10-FUNC-DEF.pdf in the Macros section, page 10-14 ff.

— Nick


On Feb 17, 2023, at 12:27 PM, Paolo Amoroso <paolo....@gmail.com> wrote:

Nick Briggs

unread,
Feb 17, 2023, 5:10:36 PM2/17/23
to Paolo Amoroso, Medley Interlisp Users/Interest
I was wrong — there are both.  But, still, try it defining a macro other than WHEN.

Larry Masinter

unread,
Feb 17, 2023, 5:28:18 PM2/17/23
to Nick Briggs, Paolo Amoroso, Medley Interlisp Users/Interest
This is an interesting discussion -- the integration of Interlisp and Common Lisp increases the complexity because there's the possibility of using Interlisp-style macros with Common Lisp and Common Lisp style macros with Interlisp.
("Interlisp-style macros" are defined with the MACRO property on the symbol, while Common Lisp-style macros are defined with DEFMACRO. Adding to the complexity is that some symbols are shared (EQ 'IL:DEFMACRO 'CL:DEFMACRO) while others are not (EQ 'CL:WHEN 'IL:WHEN) => NIL
An interesting tradeoff between compatibility (for old Interlisp programs and newer Common Lisp programs) and complexity.  

--
https://Interlisp.org for more details
---
You received this message because you are subscribed to the Google Groups "Medley Interlisp Users/Interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interlisp+...@googlegroups.com.


--

Paolo Amoroso

unread,
Feb 18, 2023, 6:07:16 AM2/18/23
to Nick Briggs, Medley Interlisp Users/Interest
On Fri, Feb 17, 2023 at 10:55 PM Nick Briggs <nicholas...@gmail.com> wrote:
Also note that WHEN is already a CLISP word, so unclear to me which definition would get precedence anyway.

You're absolutely right. I needed a sample macro and quickly put together the simplest I could think of, but I'm not meaning to use it.

--

Paolo Amoroso

unread,
Feb 18, 2023, 1:53:58 PM2/18/23
to Medley Interlisp Users/Interest
CL:MACROEXPAND-1 seems to work also with the few Interlisp macros I tested it with. But the code snippets from PDF page 282 of Kaisler's book suggest EXPANDMACRO does one expansion step like CL:MACROEXPAND-1.

Larry Masinter

unread,
Feb 18, 2023, 4:27:25 PM2/18/23
to Paolo Amoroso, Medley Interlisp Users/Interest

Paolo Amoroso

unread,
Mar 13, 2023, 4:01:23 PM3/13/23
to Medley Interlisp Users/Interest
The Medley 1.0 release notes recommended using CL:MACROEAPAND also for Interlisp macros. From page 31 of the PDF file:

Use CL:MACROEXPAND·1 to expand Common Lisp macros and those Interlisp macros that are visible to the Common Lisp compiler and interpreter.

John Cowan

unread,
Mar 14, 2023, 4:19:30 PM3/14/23
to Paolo Amoroso, Medley Interlisp Users/Interest
On Mon, Mar 13, 2023 at 4:01 PM Paolo Amoroso <paolo....@gmail.com> wrote:

The Medley 1.0 release notes recommended using CL:MACROEAPAND also for Interlisp macros. From page 31 of the PDF file:

Use CL:MACROEXPAND·1 to expand Common Lisp macros and those Interlisp macros that are visible to the Common Lisp compiler and interpreter.

That only happens IIRC if someone has taken the trouble to translate the Interlisp macro into a Common Lisp macro, which is not automatic.  It's possible to have both, because the IL macro is stored on the plist whereas the CL macro is stored in the value cell.  But fundamentally, Interlisp macros extend Interlisp and CL macros extend CL, and there's no particular reason why an extension to one language even makes sense as an extension to the other, any more than a Lisp macro would make sense as an extension to C (even if C were written in S-expressions).

Larry Masinter

unread,
Mar 15, 2023, 5:14:48 PM3/15/23
to John Cowan, Paolo Amoroso, Medley Interlisp Users/Interest
For better or worse, medley integrates cl and I’ll more closely
I’ll say more in my talk

--
LarryMasinter.net

On Mar 14, 2023, at 1:19 PM, John Cowan <co...@ccil.org> wrote:


--
https://Interlisp.org for more details
---
You received this message because you are subscribed to the Google Groups "Medley Interlisp Users/Interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interlisp+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages