Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Re: eq vs. ==

by Jenda (Abbot)
on Jul 21, 2003 at 10:52 UTC ( [id://276211]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: eq vs. ==
in thread eq vs. ==

How common is the '=' vs. '==' typo depends on which languages do you mix. If you only write in Perl and C/C++/C#/Java/JavaScript, then it's quite likely you'll not make this mistake. But if you have to write some VB or Pascal or ... then it can happen easily. OTOH, I more often write '==' in a condition in VB than '=' in Perl.

Jenda
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
   -- Rick Osborne

Edit by castaway: Closed small tag in signature

Replies are listed 'Best First'.
Re: Re: Re: Re: eq vs. ==
by liz (Monsignor) on Jul 21, 2003 at 10:58 UTC
    But if you have to write some VB or Pascal or ...

    or SQL or XSLT... ;-(

    That has tripped me up in the past and although I initially found the "2 == $var" notation very confusing, I must say it is growing on me...

    Liz

Re: eq vs. ==
by Abigail-II (Bishop) on Jul 21, 2003 at 11:01 UTC
    In Pascal (at least in the version as intended by Go^H^HWirth), you are not very likely to make that mistake. Pascal uses = to compare two values, and := for assignment. So, you'd have to type an extra character (instead of leaving one off) to make this mistake, but even if you do:
    if a := b then begin ... end
    is a compile time error. Not really a problem. In Perl using assignment instead of comparison in a condition leads to a compile time warning. However, in C, the use of assignment instead of comparison is just find, and only some compilers will warn, if you turn on the appriate warnings. But when compiling C, it's much more common (and troublesome) to turn warnings on than in Perl.

    Conclusing, when coding in Perl, and certainly in C, is more likely to make this mistake than when coding in Pascal.

    Abigail

      I did not say (or at least did not mean to say) that it's more likely to make such mistake in Pascal than in Perl. What I meant was that if you use both Perl and Pascal, it's more likely you'll make this mistake in Perl.

      Jenda
      Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
         -- Rick Osborne

      Edit by castaway: Closed small tag in signature

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-28 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found