Re: bug in optional argument processing (?)
Leon Bottou <[email protected]> Fri, 24 Mar 2006 10:48:53 -0500
| Newsgroups | gmane.lisp.lush.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thursday 23 March 2006 08:33 pm, Ralf Juengling wrote: > > Here is what Lush does: > > ? (defparameter *global-val* 5) > = *global-val* > ? (defun f (val &optional (other-val *global-val*)) > (+ val other-val)) > = f > ? (f 12) > > *** + : not a real number : *global-val* > Debug toplevel [y/N] ?n > ? That is because the default values of optional arguments are not evaluated. Workaround (de f(val &optional other-val) (setq other-val (or other-val *global-val*)) (+ val other-val) ) I simply did not want to introduce another source of dependencies between the behavior of a function and the dynamical calling context. - L. ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642