Rescue clauses on do/end blocks?

I don't think it's pretty, either. But you seem very keen on destroying
this proposal -- you say you need a way to add rescue clauses to curly
bracket blocks, and when I present one, you just dismiss it.

I'd like you to be more constructive here.

  1. Do we *really* need to allow rescue clauses
      on curly bracket blocks?

Yes.

  2. If yes, what syntax would you propose?

foo { bar rescue baz }

or

foo {
  bar
rescue
  baz
}

Personally, I don't think we need it. Curly brackets don't look like
begin/end, class/end, or def/end at all; do/end does. I've tried adding
a rescue clause to a do/end block, expecting it to work, I've never done
that with curly brackets blocks.

If we're going to have it in do/end blocks, we need it in blocks. Period.

-austin

···

On 5/19/06, Daniel Schierbeck <daniel.schierbeck@gmail.com> wrote:
--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

No, ruby itself directly contradicts you. The language defines only one difference between {/} and do/end, precedence. Increasing the differences will make ruby more about the computer than the programmer because you must remember what to put where to please the interpreter. Adding syntax is usually makes the language more complicated and that can only be bad.

···

On May 18, 2006, at 3:32 PM, Daniel Schierbeck wrote:

Eric Hodel wrote:

On May 18, 2006, at 2:24 PM, Daniel Schierbeck wrote:

dblack@wobblini.net wrote:

I'm not sure I get that distinction -- I mean, I understand that you
do it that way, but I'm not sure there's any generally closer
association between do/end and rescuing than there is between {} and
rescuing. Also, they're sometimes used in the *same* places, but by
different people :slight_smile:

Maybe it's time we make that distinction. From a syntactical point of view, they're very different

parse.y disagrees with you.

That's implementation. We ought to be able to abstract away from that, right? Isn't Ruby about the programmer, not the computer?

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Yes, but as I said -- and I know you haven't seen it as I'm writing it
-- Ruby treats them exactly the same except for precedence. I like it
that way, personally.

-austin

···

On 5/18/06, Daniel Schierbeck <daniel.schierbeck@gmail.com> wrote:

Eric Hodel wrote:
> On May 18, 2006, at 2:24 PM, Daniel Schierbeck wrote:
>
>> dblack@wobblini.net wrote:
>>> I'm not sure I get that distinction -- I mean, I understand that you
>>> do it that way, but I'm not sure there's any generally closer
>>> association between do/end and rescuing than there is between {} and
>>> rescuing. Also, they're sometimes used in the *same* places, but by
>>> different people :slight_smile:
>> Maybe it's time we make that distinction. From a syntactical point of
>> view, they're very different
> parse.y disagrees with you.
That's implementation. We ought to be able to abstract away from that,
right? Isn't Ruby about the programmer, not the computer?

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Eric Hodel wrote:

You omitted how you would specify which exceptions would be rescued.

} else { would be very confusing.

Your current solution looks entirely unlike ruby's current exception catching syntax.

Your current solution looks entirely unlike any current ruby code.

So you agree that there's no way in hell a Ruby programmer would never try to add exception handling to curly bracket blocks? Then why oh why must we support it? Why not just add exception handling capabilities to do/end blocks, period -- that's where it feels natural to add rescue clauses, anyway.

If it's possible to add clauses to do/end blocks and not {} blocks, I don't see a problem at all.

Daniel

Daniel Schierbeck wrote:

Eric Hodel wrote:

You omitted how you would specify which exceptions would be rescued.

} else { would be very confusing.

Your current solution looks entirely unlike ruby's current exception catching syntax.

Your current solution looks entirely unlike any current ruby code.

So you agree that there's no way in hell a Ruby programmer would never try to add exception handling to curly bracket blocks? Then why oh why must we support it?

Are you deliberately misunderstanding? The only agreement I saw is
that this is ugly.

Why not just add exception handling capabilities to do/end blocks, period -- that's where it feels natural to add rescue clauses, anyway.

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.

If we added it to do/end, we'd have to add it to {}. But heavens,
not using the insane syntax in your last message. Better to leave
it alone.

Furthermore, I question the need for this feature in the first place.

Hal

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>

···

On Sun, May 21, 2006 at 03:12:03PM +0900, Hal Fulton wrote:

--
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

···

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

Mauricio Fernandez wrote:

For the record, there's another difference: you cannot use do/end with
BEGIN/END.

I never knew that. Is there an obvious reason I'm not seeing?

Hal

Hi,

···

In message "Re: Curly brackets" on Mon, 22 May 2006 05:02:37 +0900, Hal Fulton <hal9000@hypermetrics.com> writes:

For the record, there's another difference: you cannot use do/end with
BEGIN/END.

I never knew that. Is there an obvious reason I'm not seeing?

Since it's from AWK, I honored the AWK syntax, and saw no need to
support do..end. Consistency? Nah.

              matz.