| any-feature documentation | view source | Contained in the any-feature distribution. |
any::feature - Backwards-compatible handling of new syntactic features
version 1.100840
use any::feature 'say';
say 'Hello, world!';
Perl 5.10 introduces new syntactic features which you can activate and
deactivate with the feature module. You want to use the say feature in a
program that's supposed to run under both Perl 5.8 and 5.10. So your program
looks like this:
use feature 'say';
say 'Hello, world!';
But this only works in Perl 5.10, because there is no feature module in
Perl 5.8. So you write
use Perl6::Say;
say 'Hello, world!';
This works, but it's strange to force Perl 5.10 users to install Perl6::Say
when the say feature is included in Perl 5.10.
Use any::feature!
WARNING: This is just a proof-of-concept.
any::feature can be used like Perl 5.10's feature and will try to "do
the right thing", regardless of whether you use Perl 5.8 or Perl 5.10.
At the moment, this is just a proof-of-concept and only handles the say
feature. If things work out, I plan to extend it with other Perl 5.10
features.
The following programs should work and exhibit the same behaviour both in Perl 5.8 and Perl 5.10.
This program will work:
use any::feature 'say';
say 'Hello, world!';
This program will fail at compile-time:
use any::feature 'say';
say 'Hello, world!';
no any::feature 'say';
say 'Oops';
The features are lexically scoped, which is how they work in Perl 5.10:
{
use any::feature 'say';
say 'foo';
}
say 'bar'; # dies at compile-time
Takes as arguments a direction (activate or deactivate), a package name
and a feature name. Activates or deactivates the given feature for the given
package.
Takes as arguments a package name and a feature name. Uses dispatch() to
activate the given feature in the given package.
Takes as arguments a package name and a feature name. Uses dispatch() to
deactivate the given feature in the given package.
Takes the same arguments as Perl 5.10's use feature pragma. Uses
activate() and deactivate() to do its job.
Takes the same arguments as Perl 5.10's no feature pragma. Uses
activate() and deactivate() to do its job.
Uses Perl::Version to get the version number of the current perl interpreter. This is used to decide the course of action.
Uses Perl::Version to get the revision number of the current perl interpreter. This is used to decide the course of action.
See perlmodinstall for information and options on installing Perl modules.
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=any-feature.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see http://search.cpan.org/dist/any-feature/.
The development version lives at http://github.com/hanekomu/any-feature/. Instead of sending patches, please fork this project using the standard git and github infrastructure.
Marcel Gruenauer <marcel@cpan.org>
This software is copyright (c) 2009 by Marcel Gruenauer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| any-feature documentation | view source | Contained in the any-feature distribution. |