[parenscript-devel] Implicit return for function bodies
sblist at me.com
sblist at me.com
Thu Nov 5 18:16:27 UTC 2009
On 2009-11-04, at 10:33 PM, Vladimir Sedach wrote:
> I just pushed a patch that should fix that. Thanks for the bug report!
Thanks for the speedy fix!
Another trickiness around SWITCH is the behavior of fall-through
cases -- it seems like there's still a bug lurking here:
PS> (ps (lambda ()
(switch 0
(1 1 break)
(2 2 break)
(3 (do-something))
(default 4))))
"function () {
switch (0) {
case 1:
return 1;
case 2:
return 2;
case 3:
return doSomething();
default:
return 4;
};
};"
I think that case 3 shouldn't return, since there was no break there
originally, so the expected behaviour is to doSomething() and then
fall-through for the return value.
- Scott
> 2009/11/4 <sblist at me.com>:
>> Hi Vladimir,
>>
>> Thanks a lot for doing this work, it'll be seriously great to have
>> implicit return!
>>
>> On 2009-11-04, at 12:57 PM, Vladimir Sedach wrote:
>>
>>> Hello,
>>>
>>> Many of you have been asking for this for a long time, and based on
>>> feedback (as well as my own experience) the lack of this feature has
>>> been the biggest cause of bugs in PS code, so it's with a bit of joy
>>> that I just pushed out a patch to add implicit returns to PS
>>> functions
>>> (including lambdas and flet/labels) to the repository just now.
>>> Please
>>> try it out and report any bugs you find!
>>
>> The first one I encountered was to do with the special return
>> handling for case/switch.
>>
>> 1) The return special form assumes the wrong switch/case
>> structure for these statements, it should be:
>>
>> (switch-case what &rest clauses)
>>
>> rather than:
>>
>> (switch-case what clauses)
>>
>> ...in both the destructing code and the reconstruction of the
>> clauses, having been updated with the return statement.
>>
>> 2) The return special form needs to handle break forms in
>> switch/case; rather than wrapping a break statement, it
>> should remove it and wrap the previous expression in the
>> return statement. Here's the (incorrect) output that I'm getting
>> after having fixed the first issue:
>>
>> (ps (lambda () (case 1 (0 1) (otherwise 2))))
>>
>> "function () {
>> switch (1) {
>> case 0:
>> 1;
>> return break;
>> default:
>> return 2;
>> };
>> };"
>>
>> I think we want to see:
>>
>> "function () {
>> switch (1) {
>> case 0:
>> return 1;
>> default:
>> return 2;
>> };
>> };"
>>
>> - Scott
>>
>> _______________________________________________
>> parenscript-devel mailing list
>> parenscript-devel at common-lisp.net
>> http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>>
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
More information about the parenscript-devel
mailing list