[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Testing list?



Peter Haworth wrote:
> 
> What's actually happening here is that the LHS is being evaluated in scalar
> context, which means that it's the scalar value of @c which is being tested for
> truth - $a and $b are evaluated, then thrown away.

Right.  I don't see this as a problem. 

The problem with the proposal, as pointed out by 
other commentators, is that the LHS would need to be
evaluated in both scalar and list contexts -- the
former for the test, the latter for the assignment -- 
and perl is currently not capable of this.


 
> So that's yet more semantics which this would change. 

I'm not proposing any changes in semantics (other than
to make the construct legal).  As I said:

         ( $a, $b, @c ) ||= ( 1, 2, 3, 4, 5 );
    would be the same as
         ( $a, $b, @c ) or
         ( $a, $b, @c ) = ( 1, 2, 3, 4, 5 );
         
I believe this could even be done as a compiler macro.
That would obviate the need to add new interpreter
semantics.  Programmers would just have to be aware that
the LHS gets evaluated twice.

-- 
John Porter

"There are people who have fun studying the C++ spec for
literally seconds on end, I'm sure..."    John Vlissides


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe