Uri Guttman <[EMAIL PROTECTED]> writes:
> >>>>> "DC" == Damian Conway <[EMAIL PROTECTED]> writes:
>
> DC> One might also envisage a C<use strict 'typing'> pragma to require
> DC> that all lexicals be typed.
>
> do you mean lexical params in a sub signature? or all lexicals in the
> current scope which contains the pragma?
>
> required typing for all lexicals feels too strong. many lexicals are
> just ordinary scalars and don't type well unless we require an
> int/string/float/ref type.
>
> what about making that mean that any scalar being assigned a method call
> (compile time checked only), must have a type? it would not be too broad
> and should be simple to check and it has useful behavior.
>
> use strict 'typing' ;
>
> my $foo = Dog.new() ;
>
> that fails at compile time.
>
> my Dog $spot = Dog.new() ;
>
> that is ok.
>
> my Canine $spot = Dog.new() ;
>
> that is ok if Dog ISA Canine. $spot could be assigned a Dog or a Cat
>
> my $foo = foo() ;
>
> is fine too, since no compile time detection of OO values is made.
You missed
my Critter $spot = AnimalShelter.choose_critter;
I'm sure you were/are aware of the possibility of factory objects etc,
but I think it's best to mention them explicitly just in case they get
overlooked...
--
Piers Cawley
www.iterative-software.com