![](https://secure.gravatar.com/avatar/5c13044077baec031cf34ffcb364519c.jpg?s=120&d=mm&r=g)
15 Nov
2008
15 Nov
'08
5:47 a.m.
Daniel Gackle wrote:
PS' implementation of &optional function arguments breaks because of JS's weird short-circuiting. For example,
(ps (defun blah (&optional (x 0)) (return x))) => "function blah(x) { x = undefined === x && 0 || x; return x; };"
With this implementation, blah() is undefined when it should return 0.
You may have noticed this, but for passer-bys I'll note that the reason for this is actually a bit nuanced. You'll notice this only occurs when your default value for x is zero. Zero is false in JS, so 0 || x always returns x even if x is undefined. Thanks for the report. I've pushed a fix for this that should be more robust to this type of thing. Cheers, -- Travis