On May 21, 2006, at 6:54 AM, Mauricio Fernandez wrote:

> On Sun, May 21, 2006 at 03:12:03PM +0900, Hal Fulton wrote:
>> Daniel Schierbeck wrote:
>>> If it's possible to add clauses to do/end blocks and not {}  
>>> blocks, I
>>> don't see a problem at all.
>>
>> That would be yet another difference between do/end and {}.
>>
>> Right now, precedence is the only difference. It works well.
>
> <unimportant-info>
> For the record, there's another difference: you cannot use do/end with
> BEGIN/END.
>
> parse.y:
> stmt		: kALIAS fitem {lex_state = EXPR_FNAME;} fitem
> [...]
> 		| klBEGIN
> [...]
> 		  '{' compstmt '}'
> [...]
> 		| klEND '{' compstmt '}'
>
> Not that it matters.
>
> </unimportant-info>
>
> -- 
> Mauricio Fernandez  -   http://eigenclass.org   -  singular Ruby
>

Well BEGIN and END almost seem like they should be control structures  
to me anyway. (Esepecially since the { } following BEGIN and END  
aren't blocks (in the sense of being yield-able or convertable to a  
proc)

% cat begin_proc.rb
p = lambda { puts "Hello" }
BEGIN( &p )


% ruby begin_proc.rb
-:2: parse error, unexpected '(', expecting '{'
BEGIN( &p )
       ^

I almost think the syntax should be

BEGIN
   ...
end

END
   ...
end

Although that does look really odd, esp. for END.

Since we use "ensure" for exceptions, that frees up finally. Why not

initially
   ...
end

and

finally
  ...
end