These don't seem orthogonal. It feels like I should be able to do
obj.meth do |x|
#...
rescue SomeException => ex
#...
end
and that either begin should be something like a Kernel method:
def begin
yield
end
(although maybe with optional "do"), or blocks could be standalone
expressions if not part of a method call (this doesn't _seem_ to cause
ambiguity, but someone cleverer could probably find some).
So I could do
do
#...
rescue SomeException => ex
#...
end
which behaves just like "begin", and I wouldn't have to use blocks in
some places (iterator methods) and begin/end in others (builtin control
structures):
do x.foo; x.bar; end if x.baz? , or
{ x.foo; x.bar } if x.baz?
instead of
begin x.foo; x.bar; end if x.baz?
The syntax difference between iterators and builtin control structures
(need the do), and the fact that one checks for require blocks and one
doesn't, still rub me the wrong way a bit:
while(foo) ... end
but
loop do ... end
^^
I don't want to know if it's a builtin or an iterator.
What do people think? I hope I'm completely wrong, and it makes perfect
sense... and someone can explain it :-)
Sam