E
ES
Listening in on the Roundtable (thanks to the brave recording crew and
Ezra Zygmuntowicz), it seems as if we were somewhat sidetracked in the
'default block parameters' discussion; the -> notation is to specifically
allow anonymous methods and the block syntax would still be allowed for,
well, blocks.
Multiple assignment was also mentioned; I am not quite sure how this plays
in, perhaps someone could clarify on that. (I always assume it is the
difference between a, b, c = 1, 2, 3 vs. a, b, c = [1,2,3].)
So here are some points I have pondered.
1. Blocks vs. Procs. I think the desire has long been to make any
differences between these two (and also Proc.new vs. Kernel.proc)
disappear.
2. Blocks/Procs versus anonymous methods. Should these be actually
*different* or should
3. Anonymous methods vs. methods. More aptly, should methods just be
special instances of anonymous methods in that they are tied to
a particular class?
4. Methods vs. Procs. Should these two be different beasts or can
the differences be implemented with context rather than content?
Now, based on my cursory YACC knowledge (and much input from a gentleman
on #ruby-lang), all these would be possible to implement with varying degrees
of difficulty. Even using the traditional block syntax with default arguments
would be
# 1. New syntax, 'easy' to implement
anon = -> (x = 'Hello') { puts x }
# 2. Also 'new' syntax though using def for this
# would require changes in, well, 'def'.
anon = def(x = 'Hello') { puts x }
# 3. Using 'lambda' (or something else) would be simpler than above.
anon = lambda(x = 'Hello') { puts x }
# 4. Implicit conversion is possible with = not being a method.
anon = {|x = 'Hello'| puts x }
# 5. The 'traditional' style.
anon = lambda {|x = 'Hello'| puts x } # Sub 'lambda' with 'def'
# 6. More? The : or . seems not necessary in this context of blocks?
Personally I would like to see the complete unification of Blocks, Anons
and Methods with the Block being the basic element of which the two others
are merely contextually created special cases; this combined with either
the def/lambda() syntax or the plain block syntax (#4 above).
Er, well, yeah. Just felt the urge to write something
E
Ezra Zygmuntowicz), it seems as if we were somewhat sidetracked in the
'default block parameters' discussion; the -> notation is to specifically
allow anonymous methods and the block syntax would still be allowed for,
well, blocks.
Multiple assignment was also mentioned; I am not quite sure how this plays
in, perhaps someone could clarify on that. (I always assume it is the
difference between a, b, c = 1, 2, 3 vs. a, b, c = [1,2,3].)
So here are some points I have pondered.
1. Blocks vs. Procs. I think the desire has long been to make any
differences between these two (and also Proc.new vs. Kernel.proc)
disappear.
2. Blocks/Procs versus anonymous methods. Should these be actually
*different* or should
3. Anonymous methods vs. methods. More aptly, should methods just be
special instances of anonymous methods in that they are tied to
a particular class?
4. Methods vs. Procs. Should these two be different beasts or can
the differences be implemented with context rather than content?
Now, based on my cursory YACC knowledge (and much input from a gentleman
on #ruby-lang), all these would be possible to implement with varying degrees
of difficulty. Even using the traditional block syntax with default arguments
would be
# 1. New syntax, 'easy' to implement
anon = -> (x = 'Hello') { puts x }
# 2. Also 'new' syntax though using def for this
# would require changes in, well, 'def'.
anon = def(x = 'Hello') { puts x }
# 3. Using 'lambda' (or something else) would be simpler than above.
anon = lambda(x = 'Hello') { puts x }
# 4. Implicit conversion is possible with = not being a method.
anon = {|x = 'Hello'| puts x }
# 5. The 'traditional' style.
anon = lambda {|x = 'Hello'| puts x } # Sub 'lambda' with 'def'
# 6. More? The : or . seems not necessary in this context of blocks?
Personally I would like to see the complete unification of Blocks, Anons
and Methods with the Block being the basic element of which the two others
are merely contextually created special cases; this combined with either
the def/lambda() syntax or the plain block syntax (#4 above).
Er, well, yeah. Just felt the urge to write something
E