On Wed, May 30, 2001 at 04:11:25PM +0900, Wayne Blair wrote:
> No matter how you name it, I don't think it states your intention
> intuitively,

Ok.

> have to understand the C-convention, which I agree sucks but POLS tells me
> to stick with an existing convention rather than introduce a new one unless it

And we are talking about Ruby and not C. But never mind, I'll use
C in just a moment.

> tryturn( scientists ) {|x| return x} in your example creates a temporary
> variable in the block.
> It also generates another method call and potentially a yield to a block.

Yes, if you write it with Ruby, but if you do it in C and in eval.c
in Ruby source, it could look something like this:

+       case NODE_TRYRETURN:
+   if (node->nd_stts) {
+       result = rb_eval(self, node->nd_stts);
+       if( RTEST( result ) )
+       {
+           return_value( result );
+           return_check();
+           JUMP_TAG(TAG_RETURN);
+       }
+   }
+   break;

Yes, it does generate method call to evaluate what is inside that
node, but that yield is not there if it is done as keyword and
not as Ruby module. I think that "TryReturn" Ruby module is ugly,
but it was only way to show my intention without sending C-code or
patch to those Ruby sources. But I fall back, above is part of
working implementation of "tryreturn".

> Anyway, your code is interesting enough to keep me thinking about it for
> awhile - would like to
> see your thoughts on additional power of this technique.

I see "tryreturn" as a somekind of variation of catch-throw
mechanism, but without strict relationship with thrower and
catcher. That is, if you want to use throw, there must be someone
to catch it (and know that you are throwing), or you get NameError.

With "tryreturn" you let that imaginary-throw to fall thru until
there is someone who is intrested in result or someone who does 
not know that you are doing "imagined throw".

> Wayne

-Jippo

-- 
 __________________________________________________________________
[   pub 1024/951AFAF5 1995/12/12   Juha Pohjalainen <jmp / iki.fi>   ]
[   fingerprint 41 56 7F F9 8E EC 16 35  BB 42 EF A7 DF 19 FA 31   ]
[__ http://www.iki.fi/jmp/ ________________ GSM +358 40 570 1179 __]