Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: What is the correct definition of False and Null in Perl?

by LanX (Canon)
on Oct 08, 2011 at 17:12 UTC ( #930371=note: print w/ replies, xml ) Need Help??


in reply to Re^2: What is the correct definition of False and Null in Perl?
in thread What is the correct definition of False and Null in Perl?

> That is because this is a special case coded into Perl.

every string starting with a number (plus leading whitespaces) evaluates to that number.

The only specialty about "0 but true" are the missing messages under "warnings".

DB<102> $a=" 41 The ultimate answer!" DB<103> print ++$a 42

I would rather prefer "0.0" or "0E0", if I was calling functions in scalar context.

Cheers Rolf


Comment on Re^3: What is the correct definition of False and Null in Perl?
Download Code
Re^4: What is the correct definition of False and Null in Perl?
by Marshall (Prior) on Oct 08, 2011 at 18:40 UTC
    The only specialty about "0 but true" are the missing messages under "warnings".

    Yes. That is correct. "0 but true" is a special case that does not emit a warning when used in a numeric expression.

    0E0 is the "standard way" of "true but zero".

    0.0 is not quite the same as 0E0. The DBI uses 0E0. Ok, maybe 0.0 could have been used, but it wasn't. I think that it is pointless to debate 0E0 vs 0.0, 0E0 has won and so let's go to another question.

      > 0.0 is not quite the same as 0E0.

      I was talking about strings not literal numbers:

      DB<105> p !! "0.0" 1 DB<106> p !! "0E0" 1 DB<107> p !! 0E0 DB<108> p !! 0.0 DB<109> p 1 + "0E0" 1 DB<110> p 1 + "0.0" 1

      and by the way IMHO thats all hardly necessary.

      Can't think of a use case which can't be solved by calling a function in list context.

      Cheers Rolf

        Well that may be true. But the issue here is what did the other guys do? When we use an interface, we have to deal with it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2014-10-26 03:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (150 votes), past polls