Michael Schwern wrote:
> mjd tricked me into reading his "Strong Typing Doesn't Have To Suck"
> talk, and now I'm looking at the typing proposals for Perl 6 and
> thinking... boy, its going to be almost as bad as C. That sucks.
>
> Is there hope? I dunno, but read the talk.
> http://perl.plover.com/yak/typing/
>
Schwern tricked me into reading mjd's "Strong Typing Doesn't Have To Suck"
which turned out to be a really well written exposition of how modern
functional languages (mjd used ML as his example) use type checking to flag
program errors without losing algorithm flexibility.
One of mjd's points about mashed potatoes is that Perl isn't ML, and ML's
typing approach doesn't fit on top of Perl very well (i.e. at all). His
other point about mashed potato is that it is a poor vector for hot fudge,
IIRC...
Stroustrup noticed the same thing (about typing, not mashed potatoes) when
looking at this issue for C++. His solution was the introduction of
'templates':
http://babbage.cs.qc.edu/STL_Docs/templates.htm
which are now used widely by C++ programmers when they access libraries such
as the STL (which is part of the Standard Library) and the very cool POOMA:
http://www.acl.lanl.gov/pooma/
Because templates provide much-needed flexibility in algorithm and class
development, C++ programmers don't have to use many of the workarounds that
mjd identified. Therefore, far more compiler warnings represent real
problems, which means that programmers are less likely to ignore them.
Perl 5 didn't need templates, because there wasn't compile-time typing. But
with Perl 6 I want to send my compact array of integers to the same fast
sum() function as my compact array of floats, and not have to wait while
perl treats them both as old generic scalars. That means that my sum()
function needs a typed parameter list. There seems to be at least two
potential solutions:
- Provide a type placeholder in the parameter list (a la C++ function
templates)
- Provide a type hierarchy for all types (a la Haskell)
- (And that 3rd option that I haven't thought of yet...)
I don't remember seeing either of these suggestions in the RFCs, but I might
have forgotten since I occassionally fail all 361 of them in my head. A
hierarchy of types is briefly referred to in RFC 4 but not really developed
to deal with this issue:
http://dev.perl.org/rfc/4.html