Damian Conway <[EMAIL PROTECTED]> wrote:
> 
> There are in fact *two* types associated with any Perl variable:
> 
>       1. Its "storage type" (i.e. the type(s) of value it can hold)
>             This is specified before the variable or after an C<of> or C<returns>.
>          It defaults to Scalar.
> 
>       2. Its "implementation type" (i.e. the class that tells it how to act)
>             This is specified after an C<is>. It defaults to the type indicated
>          by the variable's sigil.

How does it work regarding inheritance and polymorphism ?
E.g. consider
        my @a is Set of Apple;
        my @b is Basket of Fruit;
with Apple isa Fruit, and Basket is a Set.

I assume I can use @a or @b where the expected type is:

                        @a  @b
    Set                 ok  ok
    Set of Fruit        ok  ok
    Set of Apple        ok  no(?)
    Basket              no  ok
    Basket of Fruit     no  ok
    Basket of Apple     no  no(?)

the errors being compile-time or run-time, depends on how much verification the
compiler can perform with its input. Reminds me the "Set<Apple>" C++ templates.
And the whole mess that comes with it (when you've got a statically typed language.)

Reply via email to