On Mon, Feb 05, 2001 at 08:56:05AM -0200, Branden wrote:
> I don't really see what this buys us. First, `return' already handles it,
> and it finishes sub execution. How would it be handled with that? `foo = 42;
> last;'? I think `return 42;' is better... 
That's the thing.  return and setting the fname var have different primary
applications.  For a function where you compute a value and return it,
"return" is wonderful.  OTOH, for functions that look more like {startup;
compute; teardown}, magic-varable is nice.  Think of the functions where you
have a varable named $ret or somesuch, and you compute it, have another few
lines or few screens of code, and then say "return $ret".  I don't write
many of those, but sometimes they're nice.

> And `return' handles scalar/list
> context, mainly because it isn't a special variable, it is a statement. IMO,
> `return' is perfect for the job, since it combines the familiarity of
> passing a list as parameter to a statement, what is done in all practically
> all Perl statements, and has no problem with context to return a scalar or a
> list from a sub.

Yep.  That's the rub.  It doesn't "feel" like a statement, it "feels" like
an assignment.  But we still want it to have many of the nice properties of
a statement, like having list and scalar contexts.  A good solution to this
I have not; the best I can offer is two magic values, $^R and @^R.  And, as
sombodyoranother pointed out, @^R can't be a real array, only a list.  (I
don't think that will be a problem, though.)

> [stuff about manual vs. automatic return-stack elminition]
Yeah, you're probably right.  But return-as-assignment has certian nice
features from a stylistic viewpoint as well as an optimizational one.

      -=- James Mastros
-- 
"My country 'tis of thee, of y'all i'm rappin'!  Lan where my brothers
fought, land where our King was shot -- from every building top, let freedom
happen!"
        -=- Monique, Sinfest[.net]
AIM: theorbtwo       homepage: http://www.rtweb.net/theorb/

Reply via email to