IL:PSETQ confused with CL:PSETQ?

24 views
Skip to first unread message

pixel...@gmail.com

unread,
Sep 16, 2025, 2:32:01 AM (13 days ago) Sep 16
to Medley Interlisp core
Per the meeting today, I wanted to stay away from Common Lisp as much as possible and write the Fibonacci function in an InterLisp way. This would let us go through the traditional compilation and saving route without the compiler getting confused.

However as you may see, it's insisting on using CL:PSETQ...

Screenshot_20250916_002819.png

pixel...@gmail.com

unread,
Sep 16, 2025, 2:35:36 AM (13 days ago) Sep 16
to Medley Interlisp core
You may need to right click and select view image to get the full thing in another tab.
I had assumed that PSETQ being in the Dinfo manual would be a safe InterLisp function. (Otherwise I'd have used CL's SHIFTF)

Ron Kaplan

unread,
Sep 16, 2025, 3:03:58 AM (13 days ago) Sep 16
to pixel...@gmail.com, Medley Interlisp core
Hmm, I see that there is man entry for PSETQ, but I never heard of it.  And in fact, as near as I can tell, it doesn't actually exist.  Not as a function or as a macro.  And it isn't called anywhere that masterscope knows about.

The man page seems to suggest that it is equivalent to CL:PSETQ.  So maybe the symbol PSETQ is also supposed to exist in IL:?

On Sep 15, 2025, at 11:32 PM, pixel...@gmail.com wrote:

Per the meeting today, I wanted to stay away from Common Lisp as much as possible and write the Fibonacci function in an InterLisp way. This would let us go through the traditional compilation and saving route without the compiler getting confused.

However as you may see, it's insisting on using CL:PSETQ...

<Screenshot_20250916_002819.png>

--
You received this message because you are subscribed to the Google Groups "Medley Interlisp core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lispcore+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lispcore/a999d241-c437-48f2-b154-4bae7bfe9fc6n%40googlegroups.com.
<Screenshot_20250916_002819.png>

Paolo Amoroso

unread,
Sep 16, 2025, 4:41:52 AM (13 days ago) Sep 16
to pixel...@gmail.com, Medley Interlisp core
The IRM covers some Common Lisp symbols accessible from Interlisp, most notably DEFMACRO, which may be confusing. Unless there's something unusual, it's safe for user code in Interlisp files to also use Common Lisp symbols as long as they're qualified with the proper package.


--
You received this message because you are subscribed to the Google Groups "Medley Interlisp core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lispcore+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lispcore/a999d241-c437-48f2-b154-4bae7bfe9fc6n%40googlegroups.com.


--

Larry Masinter

unread,
Sep 16, 2025, 4:47:22 AM (13 days ago) Sep 16
to Ron Kaplan, pixel...@gmail.com, Interlisp core Medley
There isn’t IL:PSETQ.  And for lexical scoping special it would be different 

It isn’t insisting…. I think we added the feature of DWIM guessing a package error. In this case not an improvement 
You should. Type ‘n’ for no.

I see no man entry for I L:PSETQ
--
LarryMasinter.net

On Sep 16, 2025, at 12:03 AM, Ron Kaplan <ron.k...@post.harvard.edu> wrote:

Hmm, I see that there is man entry for PSETQ, but I never heard of it.  And in fact, as near as I can tell, it doesn't actually exist.  Not as a function or as a macro.  And it isn't called anywhere that masterscope knows about.

Paolo Amoroso

unread,
Sep 16, 2025, 5:06:32 AM (13 days ago) Sep 16
to Larry Masinter, Ron Kaplan, pixel...@gmail.com, Interlisp core Medley
The PDF version of the IRM has a PSETQ entry on page 26: https://interlisp.org/documentation/IRM.pdf#page=26


Larry Masinter

unread,
Sep 16, 2025, 5:30:41 AM (12 days ago) Sep 16
to pixel...@gmail.com, Interlisp core Medley
Apologies

I shouldn’t send email when not awake. 
--
LarryMasinter.net

On Sep 15, 2025, at 11:35 PM, pixel...@gmail.com wrote:

You may need to right click and select view image to get the full thing in another tab.
--
You received this message because you are subscribed to the Google Groups "Medley Interlisp core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lispcore+u...@googlegroups.com.

pixel...@gmail.com

unread,
Sep 18, 2025, 1:21:20 AM (11 days ago) Sep 18
to Medley Interlisp core
I think I might have a restored PSETQ for the InterLisp side.
Need to do a bit more testing and possibly some simplification.
This saves all values to gensyms then SETQ's those captured symbols to the values saved in gensyms.

Screenshot_20250917_231742.png

pixel...@gmail.com

unread,
Sep 18, 2025, 1:23:27 AM (11 days ago) Sep 18
to Medley Interlisp core
Ah,  hopefully DEFMACRO is valid on the InterLisp side, I think I saw it was valid via one of the manuals.

pixel...@gmail.com

unread,
Sep 18, 2025, 1:39:46 AM (11 days ago) Sep 18
to Medley Interlisp core
Ah had to touch up the macro after comparing it with CL. It needs to return NIL regardless after the SETQing.
Screenshot_20250917_233637-1.png

pixel...@gmail.com

unread,
Sep 18, 2025, 2:28:46 AM (11 days ago) Sep 18
to Medley Interlisp core
Arg, one last fix.
It turns out I needed LET* in the final expression but I fixed it on my side.

Paolo Amoroso

unread,
Sep 18, 2025, 4:30:34 AM (11 days ago) Sep 18
to Medley Interlisp core
Yes, as you noticed you can use DEFMACRO from Interlisp.


Nick Briggs

unread,
Sep 18, 2025, 12:00:18 PM (10 days ago) Sep 18
to pixel...@gmail.com, Lisp Core, Paolo Amoroso
As I remember it, DEFMACRO is really a Common Lisp feature... but the symbol is imported into the Interlisp package.  Other than the way the symbol prints, it's no different from using any other Common Lisp function with the package qualifier (CL:foo).  If you wanted to do this as a pure old Interlisp macro, you'd check out section 5.5 of the old IRM, and save the definition using the MACROS file package command.

If you just wanted to swap two values (as in (PSETQ A B B A)) then using the CLISPword SWAP would be an Interlisp way -- (SWAP A B) will exchange the values of A and B.

Larry Masinter

unread,
Sep 18, 2025, 3:43:25 PM (10 days ago) Sep 18
to pixel...@gmail.com, Medley Interlisp core
Actually, the current CL:PSETQ is buggy if there are more than 2 (or is it 3?) variables.
CL:MACROEXPAND-1((IL:PSETQ A B C D E F G H)) will show you ...

CL  (EVAL, MACROEXPAND-1,MACROEXPAND, MACRO-FUNCTION) treats IL macros and clisp words as they were defined as DEFMACRO.


pixel...@gmail.com

unread,
Sep 19, 2025, 12:50:34 AM (10 days ago) Sep 19
to Medley Interlisp core

Thanks for the tips all!

Today I learned about IL:SWAP as well.

Larry,
My implementation seems to be correct with the manual and 3 Common Lisp implementations.
However, as you said the generation of symbols from (GENSYM) get interned which clogs up memory.
I also recall you saying SETQ is different in InterLisp so I could be wrong too!

Of course I understand I don't know what I don't know for now but hope to fill in a few missing functions from the spec if we've got em!

Thanks for your time today Larry and Herb!

I'll include my screenshot as an attachment and hopefully it won't clog up the thread. (please see attached)
Here is the actual method so we don't have to keep manually typing it in...

```
(DEFMACRO PSETQ (&REST BINDINGS-LIST)
(LET (GENSYMS-VALS VARS-GENSYMS)
(FOR SYM-VAL ON BINDINGS-LIST BY CDDR
DO (SETQ GENSYMS-VALS (CONS (LIST (GENSYM) (CADR SYM-VAL)) GENSYMS-VALS))
(SETQ VARS-GENSYMS
(CONS (LIST 'SETQ (CAR SYM-VAL) (CAAR GENSYMS-VALS)) VARS-GENSYMS)))
(SETQ VARS-GENSYMS (REVERSE VARS-GENSYMS))
(SETQ GENSYMS-VALS (REVERSE GENSYMS-VALS))
`(LET ,GENSYMS-VALS
,@VARS-GENSYMS
NIL)))

```
Screenshot_20250918_211634-2.png

Nick Briggs

unread,
Sep 19, 2025, 2:21:48 AM (10 days ago) Sep 19
to masinter, pixel...@gmail.com, Lisp Core
Not sure why you think it's buggy...

(DEFMACRO CL:PSETQ (&REST TAIL)

   (AND TAIL `(PROGN (SETQ ,(|pop| TAIL)

                      ,(CL:IF (CDR TAIL)

                           `(PROG1 ,(POP TAIL)

                                (CL:PSETQ ,@TAIL))

                           (CAR TAIL)))

                     NIL)))


so

(CL:PSETQ A B C D E F G H) becomes

(PROGN (SETQ A (PROG1 B (CL:PSETQ C D E F G H))) NIL)

avoiding having to GENSYM by using PROG1s to capture the values on the stack.

There wasn't a PSETQ in the 1986 IRM (that I can find).  It wasn't included in the list of symbols shared by the Interlisp and  Lisp packages - which is what I would have expected, so I'm confused as to why it got documented in the Venue version of the IRM as being an Interlisp function.

-- Nick

pixel...@gmail.com

unread,
Sep 19, 2025, 3:43:30 AM (10 days ago) Sep 19
to Medley Interlisp core
This screenshot might help explain. InterLisp's CL:PSETQ on the left Steel Bank Common Lisp on the right. (see attached)
Screenshot_20250919_014124.png

Larry Masinter

unread,
Sep 19, 2025, 2:44:17 PM (9 days ago) Sep 19
to pixel...@gmail.com, Medley Interlisp core
You might want to add a (DECLARE (LOCALVARS,@GENSYM-VARS)) in IL:PSETQ in the LET that binds the gensyms to insure that it doesn't special-bind the gensyms, and calls IL:SETQ.

I think a better test case would be 

(PSETQ A (+ B C D 100) B (+ A C D 100) C (+ A B D 100) D (+ A B C 100))

define a function TEST that uses it, CL:COMPILE(TEST) and then INSPECTCODE(TEST)




Nick Briggs

unread,
Sep 19, 2025, 9:27:55 PM (9 days ago) Sep 19
to pixel...@gmail.com, Lisp Core
Guess I got caught in the same trap as the original implementor of CL:PSETQ.

Interestingly, the Medley definition of CL:PSETQ when used in SBCL (here, defining ILPSETQ) produces the expected (correct) results with your test case, when it doesn't in Medley:

SBCL:


(LET* ((A 10) (B 20) (C 30))

   (ILPSETQ A B C B C A) (LIST A B C)))


(20 20 10)


-- Nick


Larry Masinter

unread,
Sep 20, 2025, 3:01:09 PM (8 days ago) Sep 20
to Medley Interlisp core
moving the discussion to a  GitHub issue
please reply there
Reply all
Reply to author
Forward
0 new messages