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

Re: Perl 6: Static/Dynamic Strong/Weak Type Systems

by Anonymous Monk
on Apr 16, 2006 at 18:31 UTC ( [id://543677]=note: print w/replies, xml ) Need Help??


in reply to Perl 6: Static/Dynamic Strong/Weak Type Systems

"I thought Perl 5 was Strongly Typed. In what way is it Weakly Typed?"

Ha? How so? when the language even does not differentiate string and number that much.

  • Comment on Re: Perl 6: Static/Dynamic Strong/Weak Type Systems

Replies are listed 'Best First'.
Re^2: Perl 6: Static/Dynamic Strong/Weak Type Systems
by dragonchild (Archbishop) on Apr 16, 2006 at 21:29 UTC
    That just means it doesn't distinguish between types you feel are important. Strong vs. Weak typing has to do with how easy it is to coerce various types into one another. There are very specific types in Perl.
    • Scalar
    • Hash
    • Array
    • Subroutine
    • Glob
    • Format

    While you may be able to extract a scalar from an array and an array has a meaning within scalar context, that doesn't mean you can coerce the array into the scalar. Try doing any sort of meaningful work converting between formats and subroutines.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      there is a hole:
      use Devel::Peek; $foo = *foo; Dump($foo);
        Fair enough. For those who don't follow, the "hole" is that whenever an explicit glob is the RHS of an assignment, the member of the glob matching the LHS will be substituted. This is because a glob is both a type and a collection of types.

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re^2: Perl 6: Static/Dynamic Strong/Weak Type Systems
by tomazos (Deacon) on Apr 16, 2006 at 22:15 UTC
    I realize now that there is clearly no standard definition of "strongly typed".

    For me it related to type casting pointers.

    In "Weakly Typed" C/C++...

    Foo f; Foo *pf = &f; Bar *pb = (Bar*) pf; Bar& b = *pf;

    Here, f points to a piece of memory it will treat as if it was in the structure of a Foo. b points to *the same* piece of memory and instead it will treat as if it was in the structure of a Bar. Foo and Bar may have totally unrelated structures. This is what I was thinking of in terms of weak typing.

    I thought you couldn't do that in Perl - hence I called in strongly typed.

    (It looks like you might be able to something similiar with the pack/unpack magic mentioned above - although it is certainly not a common practice.)

    -Andrew.

      My favorite take...
      So what is "strong typing"? This appears to be a meaningless phrase, and people often use it in a non- sensical fashion. To some it seems to mean "The language has a type checker". To others it means "The language is sound" (that is, the type checker and run-time system are related). To most, it seems to just mean, "A language like Pascal, C or Java, related in a way I can't quite make precise". If someone uses this phrase, be sure to ask them to define it for you. (For amusement, watch them squirm.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (10)
As of 2024-04-18 08:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found