This approach should be working in some code I just pushed (ae093417db848a1). I'm not checking whether return-from is executed, but rather taking the intersection of named blocks that can only be reached dynamically with the return-from tags that are contained lexically in those blocks, and generating the wrapping try-catch in the corresponding block places based on that.
Happy hacking, Vladimir On Tue, Jun 7, 2011 at 2:07 PM, Red Daly <[email protected]> wrote: > At one point I had this implemented using try-catch unless Parenscript's > compiler could prove (rather naively) that the return-from clause was always > executed. I am usually way behind the official branch, and I'm not sure if > my changes ever made it in, and if they did if this case is a bug. Anyway > it would do something like > > function foo() { > try { > > var bar = function () { > throw { 'ps-return-foo341' : 42 }; > }; > bar(); } > catch (e) { > if ('ps-return-foo341' in e) > return e['ps-return-foo341']; > else > throw e; > }; > > verbose, but it should always work. other try-catch tricks allow lisp-style > conditions, which I detailed in a post in this list within the year. in > case of group interest the relevant code is available > at https://github.com/gonzojive/paren-psos > and https://github.com/gonzojive/parenscript > > Viva Parenscript! > > Red > > > On Tue, Jun 7, 2011 at 11:40 PM, <[email protected]> wrote: >> >> Hi, >> >> I was wondering if the BLOCK/RETURN-FROM feature in PS intends >> to support the following case: >> >> (ps (defun foo () >> (flet ((bar () (return-from foo 42))) >> (bar)))) >> >> => >> >> WARNING: Returning from unknown block FOO >> "function foo() { >> var bar = function () { >> return 42; >> }; >> return bar(); >> };" >> >> In order to try and get around the warning, I tried this: >> >> (ps (defun baz () >> (block foo >> (flet ((bar () (return-from foo 42))) >> (bar))))) >> >> => >> >> WARNING: Returning from unknown block FOO >> "function baz() { >> var bar = function () { >> return 42; >> }; >> return bar(); >> };" >> >> but that didn't seem to work. Any ideas on how to achieve lexical >> return here? >> >> - Scott >> >> >> _______________________________________________ >> parenscript-devel mailing list >> [email protected] >> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel > > > > _______________________________________________ > parenscript-devel mailing list > [email protected] > http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel > _______________________________________________ parenscript-devel mailing list [email protected] http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
