types - Perl pragma for strict type checking
use types; my int $int; my float $float; $int = $float; # BOOM compile time error!
This pragma uses the optimzie module to analyze the optree and turn on compile time type checking
my float $foo = "string"; #compile time error sub foo (int $foo) { my ($foo) = @_ }; foo("hi"); #compile time error my int $int; sub foo { my float $foo; return $foo } $int = $foo; # compile time error
Currently we support int, float, number ,string and user defined classes, the implict casting rules are as follows.
int < > number int > float float < > number number > string
Normall type casting is allowed both up and down the inheritance tree, so in theory user defined classes should work already, requires one to do use base or set @ISA at compileitme in a BEGIN block.
Return values are implicitly figerd out by the subroutine, this includes both falling of the end or by expliticly calling return, if two return values of the same sub differ you will get an error message.
Arguments are declared with prototype syntax, they can either be named or just typed, if typed only the calling convertions are checked, if named then that named lexical will get that type without the need for expliticty typing it, thus allowing list assignment from @_
None.
Please report bugs and submit patches using http://rt.cpan.org/
optimize B::Generate optimizer
Arthur Bergman, <ABERGMAN@CPAN.ORG>
Copyright 2002 by Arthur Bergman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install types, copy and paste the appropriate command in to your terminal.
cpanm
cpanm types
CPAN shell
perl -MCPAN -e shell install types
For more information on module installation, please visit the detailed CPAN module installation guide.