Subject: [clisp-list] (get-setf-expansion ''z)?

From: Raymond Toy <[email-masked]>
Date: Tue Jul 23 07:44:05 2002

Currently, (get-setf-expansion ''z) produces:

(#:G232) ;
(Z) ;
(#:G231) ;
((SETF QUOTE) #:G231 #:G232) ;
'#:G232

In typical usage, this would be converted to

(let ((#:g232 z))
  (multiple-value-bind (some-var)
    '#:g232
    (progn (do-something))))

But there is no Z variable.  We really wanted the symbol Z.

This occurs when, for example, you want to implement your own version
of shiftf (for learning) and use something like (shiftf x (cdr y) 'z).

It seems to my feeble mind that get-setf-expansion should return
something like

NIL ;
NIL ;
(#:G231) ;
((SETF QUOTE) #:G231 #:G232) ;
'Z

Then the typical usage would be

  (multiple-value-bind (some-var)
    'z
    (progn (do-something)))

My thinking must be wrong....

Ray

---

From: Sam Steingold <[email-masked]>
Date: Tue Jul 23 07:52:03 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] (get-setf-expansion ''z)?"
> * Sent on 23 Jul 2002 10:43:17 -0400
> * Honorable Raymond Toy <[email-masked]> writes:
>

'z is a constant.
(setf 'z foo) does not make sense.
am I totally confused?

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
There's always free cheese in a mouse trap.

---

From: Raymond Toy <[email-masked]>
Date: Tue Jul 23 08:15:02 2002

>>>>> "Sam" == Sam Steingold <[email-masked]> writes:

    >> of shiftf (for learning) and use something like (shiftf x (cdr y) 'z).

    Sam> 'z is a constant.
    Sam> (setf 'z foo) does not make sense.
    Sam> am I totally confused?

It's an example from the CLOCC ansi tests (that Clisp gets right, but
CMUCL doesn't).

What the shiftf is doing is setting (cdr y) to 'z, but nothing is done
with 'z, so this is ok.  (shiftf x 'z (cdr y)) is, of course, an error
since you can't setf 'z to anything.

Ray

---

From: Sam Steingold <[email-masked]>
Date: Tue Jul 23 08:30:05 2002

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] (get-setf-expansion ''z)?"
> * Sent on 23 Jul 2002 11:14:14 -0400

I see!

but you do not need to compute (get-setf-expansion '<expr>) to
macroexpand (shiftf .... <expr>)!

the point is that setting (quote foo) is impossible so
(get-setf-expansion ''z) does not make sense.

It might make sense to signal an error on (get-setf-expansion ''z),
but I see no reason to return anything useful there.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
A poet who reads his verse in public may have other nasty habits.

---

From: Raymond Toy <[email-masked]>
Date: Tue Jul 23 08:39:05 2002

>> since you can't setf 'z to anything.

    Sam> I see!

    Sam> but you do not need to compute (get-setf-expansion '<expr>) to
    Sam> macroexpand (shiftf .... <expr>)!

Well, that just means that I'd have to special case the last
expression in the macroexpander.  Possible to do, but I rather like
just running down all of the elements and calling g-s-e.

BTW, this was one of several ways I tried when I tried to add shiftf
support with multiple values for CMUCL.

    Sam> the point is that setting (quote foo) is impossible so
    Sam> (get-setf-expansion ''z) does not make sense.

    Sam> It might make sense to signal an error on (get-setf-expansion ''z),
    Sam> but I see no reason to return anything useful there.

Well, it does make some sense instead of producing an error.  You just
have to know not to try to set it.  Everything else is ok.

I don't know how clisp does this for shiftf.  From the output, it
seems that it doesn't call g-s-e on the last arg of shiftf, but it's
possible shiftf is massaging it into something else.

Ray

---

From: Sam Steingold <[email-masked]>
Date: Tue Jul 23 08:59:04 2002

calling GET-SETF-EXPANSION on the last arg to SHIFTF does not make
sense. think of (shiftf a b c 10)

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Warning! Dates in calendar are closer than they appear!

---

From: Raymond Toy <[email-masked]>
Date: Tue Jul 23 09:09:05 2002

>>>>> "Sam" == Sam Steingold <[email-masked]> writes:

    Sam> calling GET-SETF-EXPANSION on the last arg to SHIFTF does not make
    Sam> sense. think of (shiftf a b c 10)

Then what are you supposed to do for 

(shiftf (values a b) (values (cdr x) (car y)) (values 'foo (bar)))

Ok.  I guess shiftf has to do something special with the last arg, no
matter what g-s-e does, since g-s-e doesn't work for numbers.

Anyway, I'm not really arguing one way or the other.  I'm just trying
to understand.  

Ray

---

From: Sam Steingold <[email-masked]>
Date: Tue Jul 23 09:34:05 2002

> * In message <[email-masked]>
> * Sent on 23 Jul 2002 12:08:33 -0400

nope. :-)

I finally guessed why you cannot look at the CLISP sources: licensing.
(CMUCL is PD, CLISP is GNU GPL, so we can borrow CMUCL code while CMUCL
cannot. :-)

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Those who value Life above Freedom are destined to lose both.

---

From: Raymond Toy <[email-masked]>
Date: Tue Jul 23 10:48:04 2002

>> (shiftf (values a b) (values (cdr x) (car y)) (values 'foo (bar)))

    Sam> nope. :-)

After more thought, I understand much better now and agree with you.
I don't have to call g-s-e at all for the last thing because it's not
a place.

Thank you!!!!!

    Sam> I finally guessed why you cannot look at the CLISP sources: licensing.
    Sam> (CMUCL is PD, CLISP is GNU GPL, so we can borrow CMUCL code while CMUCL
    Sam> cannot. :-)

Yep.  But we can, with permission, which Bruno did give for the
rationalize function.  But I did cheat a little and looked at the
code, but didn't understand it because it uses some Clisp-specific
things (I think).

In any case, the code is totally different---I basically copied the
code from CMUCL's rotatef macro and modified it for shiftf.

Ray