The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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

DESCRIPTION

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

Currently we support int, float, number and string, 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.

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.