From: Jim Weirich Date: 2011-01-29T12:28:55+09:00 Subject: [ruby-core:34968] Re: [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] On Jan 28, 2011, at 7:45 PM, Charles Oliver Nutter wrote: > So...there are three possibilities: > 1. subroutines are a specialization of coroutines. Then it's perfectly > valid for subroutines to define things coroutines do not. > 2. subroutines are equivalent to coroutines. Then coroutines should > add [] and call and subroutines should have resuming/yielding > capabilities. > 3. coroutines are a specialization of subroutines. Then coroutines > should add [] and call, and we're done. And Knuth is wrong. I wouldn't say Knuth is wrong, but a natural language "is-a" is not always an indication of subtype (c.f. the square/rectangle paradox where a square is-a rectangle, but having square inherit separate set_width/set_height methods from rectangle would be wrong). So, I would add a 4th possibility: 4. Subroutines, fibers, Method objects, and continuations (in MRI) are all subtypes of Callable, i.e. an object that will execute some code when "called". In this view, all of the above should be LSP with the "Callable" protocol (i.e. implement call/[]). -- -- Jim Weirich -- jim.weirich@gmail.com