Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

RE: myQuestion.pl

by hedgehog (Initiate)
on Apr 11, 2000 at 13:14 UTC ( [id://7305]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to myQuestion.pl

I love the soliloque. Just one thing though - it should be:
&& by_opposing() eq "end them"))

Philosophical/religious question:

Given the tiny number of failure cases, should Perl really have two sets of comparison/equality operators?

Replies are listed 'Best First'.
RE: RE: myQuestion.pl
by turnstep (Parson) on Apr 11, 2000 at 15:44 UTC

    Which two sets? || and 'or', or perhaps <=> and 'cmp', or even > and 'gt'? None are redundant, as far as I am concerned.

RE: RE: myQuestion.pl
by btrott (Parson) on Apr 11, 2000 at 16:09 UTC
    By two sets, do you mean "eq" and "==", "gt" and ">", etc.?

    A string comparison is much different than a numeric comparison. Look:

    $string = "556foo"; $num = 556; print "string comparison equal" if $string eq $num; print "num comparison equal" if $string == $num;
    The result?
    num comparison equal
    So if these are the sets of operators that you're referring to, they're definitely not redundant; you couldn't simply drop one set and have the same functionality as you do now.

    Are you proposing that we differentiate between string and numeric comparisons in some other way than the operators?

RE: RE: myQuestion.pl
by chromatic (Archbishop) on Apr 11, 2000 at 17:38 UTC
    If Perl made a distinction between numerals in scalars and characters in scalars, yes. As the typing system is weak (that is, a combination of internal Perl magic and context determine which operation is more appropriate), it's helpful to be able to specify explicitly which kind of comparison is desired.

    That's also why you'll see empty lists and the keyword scalar sometimes -- just a way of being sure that the operation has the desired effect by enforcing context and giving hints to the internal magic.

    (Now things like && and and are merely syntactic sugar designed to make Perl Poetry more readable. Right. :)

      'and' and 'or' are not merely the syntactic sugar (1) equivalents of && and || - they have a lower precedence. I prefer using && and ||, but 'and' and 'or' come in quite handy occasionally.

      (1) A lovely phrase. I wouldn't mind if perl had more for-foreach like things, just so I could sling the phrase around more often. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://7305]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.