Re:Confess HN: Share your Immoral Hacks, Codes or Tweaks
by jrockway on Friday July 31, 2009 @05:08AM
(#734066)
What you really want are continuations.
[ Parent
| on HN ]
Re:Confess HN: Share your Immoral Hacks, Codes or Tweaks
by Hexstream on Friday July 31, 2009 @08:04AM
(#734209)
Overkill. Something really simple like Common Lisp's block/return-from would do...
Re:Confess HN: Share your Immoral Hacks, Codes or Tweaks
by bkudria on Friday July 31, 2009 @04:50PM
(#735348)
...built on top of proper continuation support.
Re:Confess HN: Share your Immoral Hacks, Codes or Tweaks
by arketyp on Friday July 31, 2009 @07:20AM
(#734164)
Pardon my presumed ignorance, but how is that?
Re:Confess HN: Share your Immoral Hacks, Codes or Tweaks
by jrockway on Friday July 31, 2009 @08:17AM
(#734227)
You implement your loop macro such that it binds some variable to a continuation, that when invoked, exits the loop. Then when you want to exit the loop, you invoke the continuation.
(Loop exits, exceptions, returns from functions, etc. are all special cases of continuations.)
This is an improvement over something like Perl's "last LABEL" statement, because you can pass the continuation around and exit the loop from anywhere you desire.