On 9/25/06, dblack / wobblini.net <dblack / wobblini.net> wrote:
> Hi --
>
> On Mon, 25 Sep 2006, Rick DeNatale wrote:
>
> > On 9/24/06, dblack / wobblini.net <dblack / wobblini.net> wrote:
> >>
> >> I am fairly certain that the return value can never be captured.  At
> >> least I can't figure out how to do it.
> >>
> >> In this:
> >>
> >>   def raise_value
> >>     x = raise
> >>   rescue
> >>     x
> >>   end
> >>
> >>   p raise_value   # nil
> >>
> >> I'm pretty sure that x is nil because of the thing where the parser
> >> sees an assignment and defines the variable.  I don't think an
> >> assignment ever actually takes place -- as witness the fact that:
> >>
> >>    x = raise || 1
> >>
> >> also leaves x as nil.
> >
> > But try:
> >
> > x = raise rescue nil || 1
> >
> > Of course this is a trivial example, but the point is that raise can
> > in fact have a value.
>
> Even more trivial:
>
>    x = raise rescue 1
>
> :-)  But I'd still say that the return value of the call to raise is
> not what's being captured in x.

Well, from a syntax point of view, it sure LOOKs like the rvalue of
the assignment is the expression "raise rescue 1"

It's an interested corner of the language.  Kernel#raise is a method
so it should have a value, even though unless it's rescued it causes a
non-local return.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/