Perl's type system is both static and very strong. It just contains very few types - scalar, hash, array, filehandle, code. (And format, but no-one uses it anymore.) You cannot convert between them and they're set at compile time.

Now, the big reply is "But scalars are strings and numbers and Perl implicitly converts between them." Yes, it does. However, look at it this way - there is a type called scalar. There are dozens of operators that work on scalars. Some of them work with the scalar one way and some work with it another way. The fact they treat the scalar differently is both consistent and documented. It doesn't change the fact that it's still a scalar and it was typed as a scalar at compile time and it will never change what it is. Static and strong typing.

Another reply is "But when you do @foo + $bar, @foo gets converted to a scalar." Well, yes, that's what it looks like. But, + is defined differently for @foo than it is for $bar. It's not conversion - it's polymorphism. :-)


In reply to Re: Static typing is mostly a waste of time by dragonchild
in thread Static typing is mostly a waste of time by johnnywang

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.