Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: Illogical logic statement

by Jenda (Abbot)
on Dec 01, 2012 at 12:44 UTC ( #1006593=note: print w/replies, xml ) Need Help??

in reply to Re^2: Illogical logic statement
in thread Illogical logic statement

Compare '15' eq '15.0' versus '15' == '15.0'! Or if this looks artificial, let's assume you've read one of the numbers from a XML file and the other from STDIN. Now both are stored as strings by Perl, strings that will be converted to numbers if needed, but still what you read from both sources were strings! How should Perl guess whether you wanted to compare them as strings or as numbers? And if Perl did try to guess, how would you make sure it guesses right?

A single comparison operator is fine for strongly typed languages, but for weakly typed like Perl and JavaScript a pair of operators works much better. Actually the shared operator for string and number comparison and another for addition and concatenation is what I dislike most about JavaScript and what leads to huge loads of errors in JavaScript code in general. formFieldName.value + 1 anyone?

Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^4: Illogical logic statement
by Anonymous Monk on Dec 01, 2012 at 12:54 UTC

    Well naturally that should be formFileName.value +++ 1


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006593]
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (15)
As of 2018-07-17 15:37 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (372 votes). Check out past polls.