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

Re: Distributive -> and indirect slices

Thread Previous | Thread Next
From:
David M. Lloyd
Date:
March 19, 2001 07:48
Subject:
Re: Distributive -> and indirect slices
Message ID:
Pine.LNX.4.21.0103190938020.13147-100000@homebody.freemm.org
On Mon, 19 Mar 2001 abigail@foad.org 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.

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.

- D

<david@freemm.org>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About