Hacker News new | ask | show | jobs
by ruricolist 3293 days ago
Could you implement arbitrary return with cl-block and cl-return-from?
2 comments

With minor Emacs Lisp compiler patch (addition of %return, %goto and %label intrinsics), it is now possible to output Lisp that is optimal.

Possible implementation (about 20 lines of code): https://github.com/Quasilyte/goism/issues/57

Not sure if "defadvice" around "byte-compile-form" is acceptable for all users.

It is technically possible, but optimal solution will require more than catch and throw (cl-lib uses them) Simple demonstration: https://pastebin.com/vXp0qPw3

Some S-expressions with `cl-return' can be rewritten to avoid the need of it (by the optimizer); not sure it covers 100% of the cases though.