develooper Front page | perl.perl5.porters | Postings from March 2001

Re: Distributive -> and indirect slices

Thread Previous | Thread Next
March 25, 2001 14:04
Re: Distributive -> and indirect slices
Message ID:
On Mon, Mar 19, 2001 at 09:45:11AM -0600, David M. Lloyd wrote:
> On Mon, 19 Mar 2001 wrote:
> > > My thinking was that not too many people use the current
> > > behaviour... maybe for Obfuscated Perl contests, but the operator could be
> > > so much more powerful than it is right now.
> > 
> > Eh, don't forget it also provides scalar context to 'method' in:
> > 
> >     $obj -> method -> other_method;
> > 
> > I don't think methods returning objects in scalar context and lists
> > in list context are obfuscated. That's what's wantarray is about, isn't?
> That behaviour wouldn't change, since the leftmost expression is a scalar.

Wait, that doesn't make sense.

    @a = $obj -> method;

calls method in list context because of the assignment. Now you are
suggesting that it should call method in scalar context because of '$obj'?

> If however you did this:
> ($obj)->method->other_method;
> The first method 'method' would be called in list context on '$obj', and
> 'other_method' would also be called in list context, once for every object
> in the return list of 'method', raising the normal error if one of the
> items returned is not an object that can 'other_method'.
> The 'obfuscated' behaviour I was referring to was that of having an
> explicit list or array on the left-hand side of the operator.

That's quite opposite of what's done now.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About