Re: ANSI compliance of check-type in various lisps
From: Steven M. Haflich (smh_no_spiced_ham_at_alum.mit.edu)
Date: 02/21/05
- Next message: Rahul Jain: "Re: need good IDE and advice"
- Previous message: Rahul Jain: "Re: Help with research"
- In reply to: Kalle Olavi Niemitalo: "Re: ANSI compliance of check-type in various lisps"
- Next in thread: Kalle Olavi Niemitalo: "Re: ANSI compliance of check-type in various lisps"
- Reply: Kalle Olavi Niemitalo: "Re: ANSI compliance of check-type in various lisps"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 21 Feb 2005 05:20:31 GMT
Kalle Olavi Niemitalo wrote:
> I think, if this were really intended, there should also be a
> variant of TYPEP that could conveniently test multiple values,
> possibly passed as multiple arguments.
Probably, except that it could not be a function. It would have
to be a macro, and perhaps a rather ugly and inefficient one.
>>(The following not carefully checked.)
>
>
> Noted. However, something in your code caught my eye, and I'd
> like to know whether it was just a glitch or reflects a deeper
> misunderstanding on either my or your part.
>
> Specifically, your setf expander sets up two temporary variables
> to hold the values of the place, i.e. the car and cdr of the
> cons. These variables are bound at the beginning of the
> setf-like operation and do not change thereafter, and the
> accessing form then just returns their values, even if the cons
> has meanwhile been changed by the storing for or by something
> else. I think this is wrong and the accessing form should read
> the values from the cons itself. Otherwise, step 4 of section
> 5.1.3 would happen too early.
I think you're right. Good catch. The only circumstance I can
see where this detail could make a difference is if this setf
expander were compounded with another expander that for some
reason used the getter a second time as aconvenient to return the
new values after performing the stores. This possibility may be
a reason for this requierment in 5.1.1.2:
The value returned by the accessing form is affected by execution
of the storing form, but either of these forms might be evaluated
any number of times.
> (define-setf-expander car-and-cdr (cons)
> "Access the CAR and CDR of CONS as two values."
> (let ((obj (gensym))
> (newcar (gensym))
> (newcdr (gensym)))
> (values `(,obj)
> `(,cons)
> `(,newcar ,newcdr)
> `(values (setf (car ,obj) ,newcar)
> (setf (cdr ,obj) ,newcdr))
> `(values (car ,obj)
> (cdr ,obj)))))
>
> (The excessive backquoting is meant to imply that callers cannot
> expect these lists to be fresh or modifiable.)
I don't understand this last comment. What is "excessive"? In any
case, there is no possibility that any of these five backquote forms
could return any shared structure across successive calls.
- Next message: Rahul Jain: "Re: need good IDE and advice"
- Previous message: Rahul Jain: "Re: Help with research"
- In reply to: Kalle Olavi Niemitalo: "Re: ANSI compliance of check-type in various lisps"
- Next in thread: Kalle Olavi Niemitalo: "Re: ANSI compliance of check-type in various lisps"
- Reply: Kalle Olavi Niemitalo: "Re: ANSI compliance of check-type in various lisps"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]