[parenscript-devel] Implicit return for function bodies

sblist at me.com sblist at me.com
Thu Nov 5 03:03:43 UTC 2009


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




More information about the parenscript-devel mailing list