[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

again) Rescue clauses on do/end blocks?

Mat Schaffer

8/25/2006 12:52:00 PM

Sorry to beat a dead horse, but I still have a question on the
optional 'begin' sentiment when rescuing exceptions. It seems like
the standing issue was with the use of it in brackets. Especially
when deciding which exception to catch or adding an ensure.

Would this be unreasonable?

foo {
blah
rescue ExceptionA
handle A
rescue ExceptionB
handle B
ensure
finish things
}

Actually, it feels a little like a goto now that I type it out. That
could be a bad sign....
-Mat

4 Answers

Rick DeNatale

8/25/2006 5:44:00 PM

0

On 8/25/06, Mat Schaffer <schapht@gmail.com> wrote:
> Sorry to beat a dead horse, but I still have a question on the
> optional 'begin' sentiment when rescuing exceptions. It seems like
> the standing issue was with the use of it in brackets. Especially
> when deciding which exception to catch or adding an ensure.
>
> Would this be unreasonable?
>
> foo {
> blah
> rescue ExceptionA
> handle A
> rescue ExceptionB
> handle B
> ensure
> finish things
> }
>

For one thing, it's syntactically incorrect, rescue can only appear
inside either a begin block, or in a method def, where def methodname
acts like begin for this purpose, or as a modifier on a single
statement.
--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...

Hal E. Fulton

8/25/2006 11:36:00 PM

0

Rick DeNatale wrote:
> On 8/25/06, Mat Schaffer <schapht@gmail.com> wrote:
>
>> Sorry to beat a dead horse, but I still have a question on the
>> optional 'begin' sentiment when rescuing exceptions. It seems like
>> the standing issue was with the use of it in brackets. Especially
>> when deciding which exception to catch or adding an ensure.
>>
>> Would this be unreasonable?
>>
>> foo {
>> blah
>> rescue ExceptionA
>> handle A
>> rescue ExceptionB
>> handle B
>> ensure
>> finish things
>> }
>>
>
> For one thing, it's syntactically incorrect, rescue can only appear
> inside either a begin block, or in a method def, where def methodname
> acts like begin for this purpose, or as a modifier on a single
> statement.

Yes, but he's proposing a change in the syntax.

Hal

Mat Schaffer

8/27/2006 6:13:00 AM

0

On 8/25/06, Hal Fulton <hal9000@hypermetrics.com> wrote:
> Rick DeNatale wrote:
> > On 8/25/06, Mat Schaffer <schapht@gmail.com> wrote:
> >
> >> Sorry to beat a dead horse, but I still have a question on the
> >> optional 'begin' sentiment when rescuing exceptions. It seems like
> >> the standing issue was with the use of it in brackets. Especially
> >> when deciding which exception to catch or adding an ensure.
> >>
> >> Would this be unreasonable?
> >>
> >> foo {
> >> blah
> >> rescue ExceptionA
> >> handle A
> >> rescue ExceptionB
> >> handle B
> >> ensure
> >> finish things
> >> }
> >>
> >
> > For one thing, it's syntactically incorrect, rescue can only appear
> > inside either a begin block, or in a method def, where def methodname
> > acts like begin for this purpose, or as a modifier on a single
> > statement.
>
> Yes, but he's proposing a change in the syntax.

Well re-proposing it anyway. I'm mostly curious if there's some
fundamental problem with it that I'm not seeing. Since this
particular syntax wasn't proposed the last time the discussion went
around.
-Mat

Austin Ziegler

8/28/2006 3:29:00 AM

0

On 8/27/06, Mat Schaffer <schapht@gmail.com> wrote:
> > >> Would this be unreasonable?
> > >>
> > >> foo {
> > >> blah
> > >> rescue ExceptionA
> > >> handle A
> > >> rescue ExceptionB
> > >> handle B
> > >> ensure
> > >> finish things
> > >> }
> > >>
> Well re-proposing it anyway. I'm mostly curious if there's some
> fundamental problem with it that I'm not seeing. Since this
> particular syntax wasn't proposed the last time the discussion went
> around.

IIRC, Matz thinks it's ugly (I can't say I disagree, even though I
desire the functionality). I think it's one of the few cases where
it's worth the ugliness to be orthogonal here.

Most people won't like how {} with rescue looks and probably switch to
do/end if the need rescue. The *only* think I can think of is maybe:

foo { bar rescue nil }

Is that still the post version?

-austin
--
Austin Ziegler * halostatue@gmail.com * http://www.halo...
* austin@halostatue.ca * http://www.halo...feed/
* austin@zieglers.ca