Artur Bergman > types-0.05 > types

Download:
types-0.05.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  3
Open  0
View/Report Bugs
Module Version: 0.05   Source   Latest Release: types-0.05_04

NAME ^

types - Perl pragma for strict type checking

SYNOPSIS ^

  use types;
  my int $int;
  my float $float;
  $int = $float; # BOOM compile time error!

ABSTRACT ^

This pragma uses the optimzie module to analyze the optree and turn on compile time type checking

SYNOPSIS ^

    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

DESCRIPTION ^

This pragma uses the optimzie module to analyze the optree and turn on compile time type checking

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

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

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 @_

EXPORT

None.

BUGS ^

Please report bugs and submit patches using http://rt.cpan.org/

SEE ALSO ^

optimize B::Generate optimizer

AUTHOR ^

Arthur Bergman, <ABERGMAN@CPAN.ORG>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: