Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: == and != don't work as expected

by Vautrin (Hermit)
on Aug 09, 2004 at 15:08 UTC ( [id://381259]=note: print w/replies, xml ) Need Help??


in reply to == and != don't work as expected

Perl is a weakly typed language. Unlike C, for isntance, if you wanted to create a number then a string you could do:
my $string = 1; $string = "code"; # we can reuse the variable name
versus:
char* mystring = "this is a C style string"; int myInt = 1; // Can't reuse variable names // plus need to declare the type
You will find this paradigm called DWIM (Do What I Mean) by a lot of people. Basically, part of the price we pay for DWIM is that the interpreter doesn't choke and die on ambiguities, but makes a best guess.

Replies are listed 'Best First'.
Re^2: == and != don't work as expected
by chromatic (Archbishop) on Aug 09, 2004 at 17:23 UTC
    Perl is a weakly typed language.
    <mini_rant>

    No, it's not. It just doesn't associate the type with the name, as you might expect. Try coercing a hash to an array in place or treating a scalar as an array, for example.

    C's typing system is only slightly more advanced than bare assembly code.

    </mini_rant>
      Out of curiousity, can you name some weakly typed languages with your definition?

      Want to support the EFF and FSF by buying cool stuff? Click here.

        Assembly, C, C++ (where it copies C), and Java all have weak type systems, according to this definition.

        Don't mistake a static system which requires knowing type information at compile time with a strong system which, when it has any meaning at all, usually means that you can't (or don't need to) subvert the type system.

        If you have to cast to do your work, you have a weak type system.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-24 10:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found