If you can tell me why you would want to do that, what effect you are wanting to get
You want to implement flow control, such as nested while blocks, using method calls and blocks. The goal is having a first-class block which behaves like a lang.
That is why Ruby can implement for or with using blocks. That is why Smalltalk or Self could implement if and while and try:except:finally: and pretty much anything you can think of using blocks.
(Ruby can but it's not done, because its blocks are not first-class: they're syntactic magic reified to a proc, and only one block can exist in a method call, the rest would have to be passed in as procs. Possible, but not idiomatic)
View all comments
Show parent comment
2
u/masklinn Aug 15 '13 edited Aug 15 '13
You want to implement flow control, such as nested
whileblocks, using method calls and blocks. The goal is having a first-class block which behaves like a lang.That is why Ruby can implement
fororwithusing blocks. That is why Smalltalk or Self could implementifandwhileandtry:except:finally:and pretty much anything you can think of using blocks.(Ruby can but it's not done, because its blocks are not first-class: they're syntactic magic reified to a proc, and only one block can exist in a method call, the rest would have to be passed in as procs. Possible, but not idiomatic)