[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: #f = #none ?
- To: Bob Kerns <email@example.com>
- Subject: Re: #f = #none ?
- From: Jim Mayer <firstname.lastname@example.org>
- Date: Thu, 19 Nov 1992 11:41:07 PST
- Cc: email@example.com (Sam Pilato), firstname.lastname@example.org, email@example.com
- In-reply-to: Your message of "Thu, 19 Nov 92 10:44:37 PST." <9211191844.AA06242@taunton.crl.dec.com>
> From: Bob Kerns <firstname.lastname@example.org>
> Date: Thu, 19 Nov 92 10:18:44 EST
> From: email@example.com (Sam Pilato)
> (multiple-value-call #'foo
> (if frob-p
> (values :frob frob-val)
> :blech bletch-val)
> I agree with Fry. I would much prefer being able to:
> (foo :frob (if frob-p frob-val <use-the-default-value>)
> :blech bletch-val)
In my experience with common lisp, I have often wished for a value
that could be conventionally used to indicate "the default". Often
NIL ends up being used that way (but suffers from the usual punning
problems). For example, I have run into the following sort of
construct a number of times:
(define-method my-method (#rest args #key thing)
(apply fubar-1 thing: <use-the-default> another-thing: ... args))
Without some way to specify "use the default value for THING" one
either has to know what value to assign to THING, or operate on the
Another, perhaps more important, advantage of allowing #none is that
is simplifies the semantics of default value assignment. We could
define the defaulting semantics for keyword arguments as follows:
(define-method my-method (#key ((a1 t1) v1) ((a2 t2) v2) ...)
... stuff ...)
(define-method my-method (#key pa1 pa2 ...)
(bind (((a1 t1) (if (eq pa1 #none) v1 pa1))
((a2 t2) (if (eq pa2 #none) v2 pa2))
... stuff ...))
> I wasn't disagreeing with Fry. But I would not like there
> to be some distinguished value which could not be passed
> in, because it would be interpreted as "use the default value".
> What if you remodularize your code, so that the appropriate
> place to do the defaulting is not in that function, but instead
> in a function three levels of call down?
Why is that a problem? Under the semantics I gave above, #none is a
perfectly good value. If no default is given, it is passed right
through and the "right" thing would happen at the fuction that was
prepared to do the defaulting.
> The multiple-value-call construct has the correct semantics.
> The syntax is awkward. However, you can package it up in
> (defaulting foo :frob (if frob-p frob-val :use-default)
> :blech bletch-val).
-- Jim Mayer
Phone: (716) 422-9407
Webster Research Center Intelnet phone: 8*222-9407
Xerox Corporation Internet Email: firstname.lastname@example.org
800 Phillips Road, 0128-29E XNS Email: James L Mayer:Wbst128:xerox
Webster, New York 14580 Facsimile: (716) 265-7133