develooper Front page | perl.perl6.language | Postings from August 2001

Re: Will subroutine signatures apply to methods in Perl6

Thread Previous | Thread Next
From:
Piers Cawley
Date:
August 25, 2001 03:17
Subject:
Re: Will subroutine signatures apply to methods in Perl6
Message ID:
m3u1ywv41a.fsf@iest.bofh.org.uk
Uri Guttman <uri@sysarch.com> writes:

> >>>>> "DC" == Damian Conway <damian@mail.csse.monash.edu.au> 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


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About