It looks like this change broke the &KEY-OBJECT parameter (at least for my branch).
I forgot that even existed. Did it break for JS target version >= 1.6, or the regular method?
It also seems to incorrectly identify non-keyword arguments that happen to match keyword args
(defun xxx (&key foo) foo)
(xxx :bar :foo :foo 7) ;; => 'foo', but should be 7
Thank you for noticing that. Fixing the code is not trivial (unless there's an easy way of saying "find indexOf only at odd indices"), so there would really not be much difference between the two versions of the generated code in terms of size. I've decided to just remove the indexOf approach entirely.
Vladimir
I don't mind the loop approach, though it would be nice to lessen the generated code.
Red
On Tue, Aug 17, 2010 at 10:33 PM, Vladimir Sedach vsedach@gmail.com wrote:
I pushed a patch that simplifies keyword and optional parameter processing.
I don't know what browsers you're targeting, but if you want even less noise, set *js-target-version* to 1.6 and it will use Array.indexOf to get at the keywords.
Vladimir
2010/8/4 Daniel Gackle danielgackle@gmail.com:
The code that's generated for a keyword argument goes like this: (ps (defun foo (&key a) (bar a))) => (abbreviated for clarity): "function foo() { var a; // ... pick out and assign keyword args ... if (a === undefined) { a = null; }; return bar(a); };" It seems to me that this could be made tighter as follows: "function foo() { var a = null; // ... pick out and assign keyword args ... return bar(a); };" The only difference I can think of is when someone explicitly passes undefined as a value for the argument, but that's an oxymoronic thing to do. Can anyone think of a reason not to make this change? I like PS's keyword arguments a lot, but the generated JS is bloated enough to make me wince. _______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel