[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fixing optional arguments?



    Date: Wed, 27 Aug 1986  13:51 EDT
    From: "Scott E. Fahlman" <Fahlman@C.CS.CMU.EDU>

    This could be done by convention, without any change to the language, as
    long as both the caller and the callee know and observe the same
    convention.

Sure, but I think that misses the point.  Suppose I have a function that
looks like
	(defun foo (a &optional b c &rest d &key e)
	  ...)
and somebody calls it with B or C being the value of unsupplied-...  That
means I would have to put a prelude function in that looks roughly like
	(tagbody
	  (cond ((eq b unsupplied...)
		 (go b-is-unsupplied))
		((eq c unsupplied...)
		 (go c-is-unsupplied)))
       b-is-unsupplied
	  (setq c unsupplied...)
       c-is-unsupplied
	  (setq d nil
		e unsupplied...))
	  (setq c unsupplied...)
	  (go c-unsupplied))
in order to make all the unsupplieds consistent.  

It also means I can't
	(when (not b)
	  (setq b (compute-b-default)))
since B is not NIL.  This is a rather major change to the language.
There is probably some validity behind it someplace, but history
probably won't allow it.

Gregor, does multiple-value-call solve any of your problems?
	(multiple-value-call #'bar
	  arg-1 arg2
	  (if <something>
	      (values)
	      (values arg-3 arg-4)))
?