Robert Rothenberg > Gives > Gives

Download:
Gives-v0.1.0.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.1.0   Source  

NAME ^

Gives - Uses Want to add Perl types to subroutines

SYNOPSIS ^

  use Gives;

  sub my_func : Gives('LIST') {
    ...
    return @some_list;
  }

  @val = my_func();  # ok

  $val = my_func();  # causes an error

DESCRIPTION ^

This package uses Want to add some rudimentary context checking to subroutines. It allows you to avoid using a subroutine or method in the wrong context.

It does not check the type returned by the function. If you want to enforce return types, use Variable::Strict::Types. (You may be able to use both packages together.)

You specify the context using the Gives attribute:

  sub my_func : Gives( @Contexts ) {
  }

where @Contexts is a list of contexts accepted by Want (see the package documentation for valid contexts).

CAVEATS AND KNOWN ISSUES ^

This is an experimental package. There may be bugs.

There may be incompatabilities with Class::Std.

SEE ALSO ^

  Want
  Attribute::Context
  Sub::Context
  Attribute::Signature
  Attribute::Types
  Variable::Strict::Types

AUTHOR ^

Robert Rothenberg <rrwo at cpan.org>

Suggestions and Bug Reporting

Feedback is always welcome. Please use the CPAN Request Tracker at http://rt.cpan.org to submit bug reports.

LICENSE ^

Copyright (c) 2006 Robert Rothenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: