David Storrs writes:
> On Tue, Feb 15, 2005 at 11:06:51AM -0800, Larry Wall wrote:
> > 
> > But what y'all are talking about above is the other end--the return
> > type.  And maybe we need to enforce a newbie-friendly invariant on
> > that end as well.  I suppose we could default to not accepting
> > junctional return values by default, and have a pragma to turn it
> > on.  Or perhaps the problem isn't returning junctions per se, but
> > storing them into a variable that the user is thinking of as a
> > simple scalar value.
> 
> Pardon me while my brain autothreads:
> 
>        - But restrictions aimed at newbie-friendliness are a drag!
>        People are only newbies for a little while, and they are
>        intermediate-to-expert for a lifetime!  Isn't the whole
>        philosophy of Perl "we will trust that you know what you're
>        doing and only enforce the B&D if you ask for it"?

Yeah, but I wouldn't say that experienced programmers would see anything
off about this at first glance:

    sub stuff($x) {
        $access++;
        # do stuff with $x
    }

    my $ret = Module::foo();
    say $access;   # 10
    stuff($ret);
    say $access;   # 15

And then they find that $access has been incremented five times in one
call.  This is a bad debugging situation.

Indeed, marking junctions with a secondary sigil has been one of my
wants as an implementor.  In fact, we have to mark when things are tied
in order to cope with implementation limitations.  What if junction
variables are just tied variables.  We return tied stuff all the time;
that's how lvalue methods work. 

The question is how do we mark them.   Secondary sigil is one way:

    my $~ret = Module::foo();

But is "this variable is tied" something the programmer should think
every time he uses it?

We could do:

    my $ret is tied = Module::foo();
    stuff($ret);

Making junctions a pragma as Larry suggests seems something like the
mistake of "use integer" (but to a much lesser degree).  The question
seems not to be whether you want junctions in general, but whether
you're expecting a junction from a particular place.

And sometimes you just want ultimate versatility, in which case:

    use tied <everything>;

Should work as "use junctions".

This might even, er, tie in to the message I sent earlier today about
what @ and % mean.

Luke

Reply via email to