3 ms·
The use case mentioned can be fulfilled by another feature ruby already has, if I'm not mistaken: first-class continuations. Simply have "return" be syntactic s
by rntz 17y ago
The use case mentioned can be fulfilled by another feature ruby already has, if I'm not mistaken: first-class continuations. Simply have "return" be syntactic sugar for invocation of a contination that is implicitly created by a "def"-defined function. No need for a separate type of object, just add some syntactic sugar and hey presto.
- abecedarius 17y agoAlso, you don't need full continuations for this, just continuations with dynamic extent. (E works this way, plus it defines 'return' as syntactic sugar for calling the enclosing method's continuation.) Since I don't know much Ruby I'm not sure if its blocks have other advantages.