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

Re: unexpected result of stringification.

Thread Previous | Thread Next
Nick Ing-Simmons
March 20, 2001 03:14
Re: unexpected result of stringification.
Message ID:
<> writes:
>> So my stance is that $1 is lazy, if you want/need a copy then write "$1".
>The problem isn't $1. $1 is just a figurant in this drama, and its role
>could be played by any other variable. 

Okay - I said that a while back.

>The lead role is &&. The example
>might be bad, but if you think that's caused by &&, you are missing the
>point. It's && that returns aliases, instead of the expected values.
>Here's another example that shows the problem lies with &&:
>    print +(($x = 2) && $x) + (($x = 3) && $x);
>That will print `6', not `5'. Or is "$x" lazy as well?

Probably not.

>As for "$1 is lazy", I say Eh? The word `lazy' turns up a whopping four
>times in the 5.6.0 pods, and none of them in the meaning you are using.

Sorry, a more perl-ish usage would be 'magical' but using that in 
normal english has wrong conotations.

>Lazy evaluation has a well defined meaning, but it belongs in the class
>of functional languages, where order of evaluation is not important.
>In the class of imperative languages, lazy evaluation doesn't make sense,
>as the side-effects, and the order in which they happen are vital to write

None the less perl's 'magical' variables share the order of evaluation
issues with "lazy evaluation". $1 does not "become" the matched range
until it is used.  

Nick Ing-Simmons <>
Via, but not speaking for: Texas Instruments Ltd.

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