develooper Front page | perl.perl6.compiler | Postings from March 2005

Re: [Pugs] short-circuit operators

Thread Previous | Thread Next
From:
Andrew Savige
Date:
March 15, 2005 16:07
Subject:
Re: [Pugs] short-circuit operators
Message ID:
20050316000745.92897.qmail@web50802.mail.yahoo.com
--- Ingo Blechschmidt wrote:
> Andrew Savige wrote:
>> The following program:
>>
>> my $x = 1;
>> my $y = 2;
>> $x == 1 or $y = 42;
>                 ^ typo?

No, it's not a typo. I was (perhaps not very clearly) trying to
demonstrate that the short-circuiting operators, namely:

    or  and  &&  ||

are not short-circuiting in Pugs, at least that's what I see.
I am assuming that the above test program is valid in p5 and p6,
and with the same semantics -- if I'm mistaken, please let me know.

Here is a similar test program for the 'and' operator:

my $x = 1;
my $y = 2;
$x == 3 and $y = 42;
print"x='$x' y='$y'\n";

which again produces different results with p5 and pugs.

BTW, the program I'm trying to convert, often does things like:

    open(...) or die "...";

/-\


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

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