Jeremy Howard wrote:
\
> 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 haven't been tricked into reading MJD's article yet, but might your
third option be multiple functions with parameter-type-based dispatch?
We can do that with perl 5, but it isn't automatic.


 
> 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

Stuff about polymorphism and multiple dispatch was supposed to touch on
these
issues, bog only knows if it did or not.


-- 
                                           David Nicol 816.235.1187
      Series EE bonds can be exchanged for Series HH savings bonds.

Reply via email to