Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: There's Only One Way To Do It

by hardburn (Abbot)
on Apr 07, 2004 at 03:18 UTC ( [id://343177]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: There's Only One Way To Do It
in thread There's Only One Way To Do It

Not quite. Realize that the definitions of "strong" and "static" typing are orthogonal, and I wish there was a completely different terminology used, since they are so easily confused. "Strong" means you can't convert between the types easily. "Static" means the compiler has some idea of what the type is. "Weak" is the opposite of "strong", and "dynamic" is the opposite of "static".

Since you can't convert an array into a scalar, this aspect of Perl is strongly typed. Since a scalar can hold pretty much anything (strings, numbers, references, etc.), this aspect is dynamically typed.

Static typing, IMHO, is extremely overrated. Since many statically typed languages make it easy to cast one type into another, you can't trust it to be anything more than an optimization hint.

----
: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re^6: There's Only One Way To Do It
by disciple (Pilgrim) on Apr 07, 2004 at 03:45 UTC

    Thanks for the clarification. From your definition, isn't Perl weakly typed in addition to strongly typed? Because in a scalar you can store a string or number (and other things as well). And Perl easily converts between numbers and strings for you.

      Howdy!

      That depends on what you mean when you say "type". I chose to set the values for "type" as "scalar", "array", and "hash", being the fundamental data types (and ignoring some other, more esoteric, flavors). The number/string distinction is, in my consideration, not a part of the "type"; numbers and strings are each scalars.

      Think of them as an external representation. Some data may not have a meaningful numeric representation, but consider also a hex representation as another flavor. Regardless of the representation, the datum is a single item -- a scalar. It may be an encoding of multiple values that can be teased apart, but that, again, does not make it then a hash or an array.

      yours,
      Michael

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-29 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found