Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Why no warnings for 1 in void context?

by Not_a_Number (Parson)
on Jul 16, 2005 at 17:03 UTC ( #475481=note: print w/ replies, xml ) Need Help??


in reply to Why no warnings for 1 in void context?

A scalar constant in a void context will result in a warning, unless this constant evaluates to a numeric value of 1...

Actually, the same is true of zero:

% perl -wce 0 -e syntax OK

Given dave_the_m's explanation above, is this to allow:

0 until ....

??


Comment on Re: Why no warnings for 1 in void context?
Select or Download Code
Re^2: Why no warnings for 1 in void context?
by tlm (Prior) on Jul 17, 2005 at 12:58 UTC

    Actually, the same is true of zero:

    % perl -wce 0 -e syntax OK

    Yes, thank you, and also of undef and (), and of any list whose elements are the scalars already identified; e.g.:

    % perl -wce '( 1, 0, undef, , "di foo", "ds bar", "ig baz" )' -e syntax OK

    Given dave_the_m's explanation above, is this to allow:

    0 until ....
    ??

    Reading between the lines, I gather that you are attaching some significance to the boolean value of the constant in question. I did too on a first reading, but then I realized that it is the boolean value of what follows the while or until that matters. I.e.,

    1 while some_condition_with_side_effects;
    has the same effect as
    0 while some_condition_with_side_effects;

    the lowliest monk

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://475481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2015-07-04 23:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls