NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Missing One (Score:1)
Perl's static type system cares more about containers than values. Ponder that for a while, if you really want to confuse the debate.
Re: (Score:2)
That's actually a point explicitly raised in the article. Dynamic systems focus tracking what kinds of data are used in a system, not on syntactic evaluation of expressions. See the "Problems with Common Definitions" section which begins with this:
Re: (Score:1)
That's not quite the same. Perl 5's built-in static types are scalar, array, and hash (and Maybe reference, if you pardon the Haskellish pun). You do get compile-time checks on using them appropriately.
Re:Missing One (Score:2)
The important point is that Perl's type system is still primarily dynamic in nature, though as the article points out, static languages all have dynamic elements and vice versa. Perl's compiler is incapable of arbitrary reasoning about the adding two scalars together. They might be overloaded. They might be overloaded at runtime. They might have strings, they might have numbers, etc.
Perl's extremely limited type system in fact, must be explicitly requested:
If if you do ask for extra compile time checks, they're easy to subvert:
What? I don't have a hashref of arrayref of hashrefs! Or we can get the less common but more obscure error messages:
I know why that error is thrown, but that's only because I now know how Perl parses that.
Another example of having good type systems is exemplified in Tom Moertel's article on using types to prevent injection attacks [moertel.com]. With Perl 6's grammars, we'll be able to achieve similar goals, but Perl 5 just ain't there because while Perl 5 can do the same thing, it cannot do the same thing easily because static typing is heavily dependent on static evaluation of expressions. Many of my favorite Perl 5 modules are ones I can't use in production because the best they can do is fake things like this with source filters.
In short, as the article points out, static typing is really based on having extra (and potentially mutable) domain-specific information embedded directly into the syntax of a language (and I'm not referring to explicit typing. That's a holdover from days when compilers needed that). Perl 5 doesn't have the arbitrary flexibility to do that. Perl 6 will. I don't think this means that Perl 6 will necessarily be static, but we have the potential.
Reply to This
Parent