4 ms·
As a non ruby dev... This "block" malarkey has always seen slightly deranged to me. You know what would be even nicer syntax? Proper higher order functions! Ha
by bruce343434 3y ago
As a non ruby dev... This "block" malarkey has always seen slightly deranged to me. You know what would be even nicer syntax? Proper higher order functions!
Haskellish syntax example:
execute f = f "test response"
perform = execute
perform print
- justjust 3y agoYour code is very limited. Blocks allow you to return any type of object or to have any kind of side effects, the result is not limited to be an IO monad. Also in Haskell you can't use variable number of arguments and the syntax is very different (curry by default of first argument), so no way to translate haskell style to ruby.
- ghusbands 3y agoYour proposal ignores that Ruby blocks support `break`, `next` (continue), `return` and exceptions.
- zwp 3y agodef execute(f) f.call "test response" end perform = TOPLEVEL_BINDING.method(:execute) perform.call Kernel.method(:puts)