RubyBlocksVsSmalltalkBlocks

Last edit April 24, 2013
Are these things really the same?

  • If I return from a SmalltalkLanguage block I wind up back in the scope where it was defined. It is effectively a continuation.
  • If I return from a RubyLanguage block I wind up back in the scope of the caller. It is effectively a lambda.

Am I misunderstanding or what?

    require "Continuation"
    callcc do | ret |
       (1..10).each do | i |
          ret i
       end
     end

This replicates the SmallTalk behavior. So, they are the same thing, but with different concepts of return. See CallCc.


See also SmalltalkBlocksAndClosures, BlocksInRuby, BlocksInManyLanguages
CategoryRuby CategorySmalltalk