Perl6-Export-0.009/000755 000765 000765 00000000000 12624707467 013374 5ustar00damian000000 000000 Perl6-Export-0.009/Changes000755 000765 000765 00000001500 12624707466 014665 0ustar00damian000000 000000 Revision history for Perl extension Perl6::Export. 0.01 Sat Oct 11 23:28:24 2003 - original version; created by h2xs 1.22 with options -A -P -X -f -n Perl6::Export 0.02 Thu Nov 20 04:54:30 2003 0.03 Tue Dec 16 11:54:34 2003 - Improved handling of tags - Added ALWAYS tag 0.05 Fri Feb 27 04:10:29 2004 - Changed groups and ALWAYS to require prefix colon (as is likely in Perl 6) 0.05 Fri Feb 27 04:17:49 2004 0.06 Tue Mar 9 02:55:46 2004 - Changed interface in line with Larry's recent design decisions 0.07 Tue Mar 9 02:58:16 2004 - Minor doc bug fix 0.008 Sat Oct 3 20:26:28 2015 - Fixed problems when exporting under 'use strict' - Added support for Perl 6 IMPORT blocks - unknitted POD nit (thanks Steve) - Added META files (thanks Jarkko) 0.009 Tue Nov 24 09:12:06 2015 Perl6-Export-0.009/demo/000755 000765 000765 00000000000 12624707467 014320 5ustar00damian000000 000000 Perl6-Export-0.009/lib/000755 000765 000765 00000000000 12624707467 014142 5ustar00damian000000 000000 Perl6-Export-0.009/Makefile.PL000755 000765 000765 00000001023 12624706335 015336 0ustar00damian000000 000000 use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Perl6::Export', AUTHOR => 'Damian Conway ', VERSION_FROM => 'lib/Perl6/Export.pm', ABSTRACT_FROM => 'lib/Perl6/Export.pm', PL_FILES => {}, LICENSE => 'perl', PREREQ_PM => { 'Filter::Simple' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Perl6-Export-*' }, ); Perl6-Export-0.009/MANIFEST000755 000765 000765 00000000512 12624707467 014526 0ustar00damian000000 000000 Changes lib/Perl6/Export.pm Makefile.PL MANIFEST README t/1.t t/lib/TestModule.pm demo/Demo_Export.pm demo/Demo_IMPORT.pm demo/demo_IMPORT.pl demo/demo_export.pl META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Perl6-Export-0.009/META.json000644 000765 000765 00000001601 12624707467 015013 0ustar00damian000000 000000 { "abstract" : "Implements the Perl 6 'is export(...)' trait", "author" : [ "Damian Conway " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.142690", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Perl6-Export", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Filter::Simple" : "0" } } }, "release_status" : "stable", "version" : "0.009" } Perl6-Export-0.009/META.yml000644 000765 000765 00000001007 12624707467 014643 0ustar00damian000000 000000 --- abstract: "Implements the Perl 6 'is export(...)' trait" author: - 'Damian Conway ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.142690' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Perl6-Export no_index: directory: - t - inc requires: Filter::Simple: '0' version: '0.009' Perl6-Export-0.009/README000644 000765 000765 00000001402 12624707466 014250 0ustar00damian000000 000000 Perl6::Export version 0.009 ========================= This module prototypes the Perl 6 'exported' and 'exportable' traits in Perl 5. Instead of messing around with @EXPORT arrays, you just declare which subs are to be exported (or are exportable on request) as part of those subs. For example: sub foo is exported { # by default ... } sub bar is exportable { # on request ... } INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: Filter::Simple COPYRIGHT AND LICENCE Copyright (C) 2003 Damian Conway This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Perl6-Export-0.009/t/000755 000765 000765 00000000000 12624707467 013637 5ustar00damian000000 000000 Perl6-Export-0.009/t/1.t000755 000765 000765 00000001107 10017542044 014144 0ustar00damian000000 000000 # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 1.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use lib 't/lib'; use Test::More tests=>5; use TestModule qw(:Q bar other); ok(foo, "Exported &foo (always)"); ok(bar, "Exported requested &bar"); ok(qux, "Exported grouped &qux"); ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. Perl6-Export-0.009/t/lib/000755 000765 000765 00000000000 12624707467 014405 5ustar00damian000000 000000 Perl6-Export-0.009/t/lib/TestModule.pm000755 000765 000765 00000000474 10022024246 017011 0ustar00damian000000 000000 package TestModule; use Perl6::Export; sub foo is export(:MANDATORY) { return 1; } sub bar is export { return 1; } sub qux is export(:Q) { return 1; } sub import { Test::More::ok(1, "Invoked Module::import"); Test::More::ok("@_" eq "TestModule other", "Module::import received correct args"); } 1; Perl6-Export-0.009/lib/Perl6/000755 000765 000765 00000000000 12624707467 015132 5ustar00damian000000 000000 Perl6-Export-0.009/lib/Perl6/Export.pm000755 000765 000765 00000013252 12624707466 016756 0ustar00damian000000 000000 package Perl6::Export; our $VERSION = '0.009'; my $ident = qr{ [^\W\d] \w* }x; my $arg = qr{ : $ident \s* ,? \s* }x; my $args = qr{ \s* \( $arg* \) | (?# NOTHING) }x; my $defargs = qr{ \s* \( $arg* :DEFAULT $arg* \) }x; my $proto = qr{ \s* (?: \( [^)]* \) | (?# NOTHING) ) }x; sub add_to { my ($EXPORT, $symbol, $args, $decl) = @_; $args = "()" unless $args =~ /\S/; $args =~ tr/://d; return q[BEGIN{no strict 'refs';] . q[use vars qw(@EXPORT @EXPORT_OK %EXPORT %EXPORT_TAGS );] . qq[push\@$EXPORT,'$symbol';\$EXPORT{'$symbol'}=1;] . qq[push\@{\$EXPORT_TAGS\{\$_}},'$symbol' for ('ALL',qw$args)}$decl]; } sub false_import_sub { my $import_sub = q{ use base 'Exporter'; use vars qw(@EXPORT @EXPORT_OK %EXPORT %EXPORT_TAGS ); sub import { my @exports; for (my $i=1; $i<@_; $i++) { for ($_[$i]) { if (!ref && /^[:\$&%\@]?(\w+)$/ && ( exists $EXPORT{$1} || exists $EXPORT_TAGS{$1}) ) { push @exports, splice @_, $i, 1; $i--; } } } @exports = ":DEFAULT" unless @exports; __PACKAGE__->export_to_level(1, $_[0], ':MANDATORY', @exports); goto &REAL_IMPORT; } }; $import_sub =~ s/\n/ /g; $import_sub =~ s/REAL_IMPORT/$_[0]/g; return $import_sub; } my $MANDATORY = q[BEGIN{$EXPORT_TAGS{MANDATORY}||=[]}]; use Filter::Simple; use Digest::MD5 'md5_hex'; FILTER { return unless /\S/; my $real_import_name = '_import_'.md5_hex($_); my $false_import_sub = false_import_sub($real_import_name); my $real_import_sub = ""; s/ \b sub \s+ import \s* ([({]) /sub $real_import_name$1/x or s/ IMPORT \s* ([{]) /sub $real_import_name$1/x or $real_import_sub = "sub $real_import_name {}"; s{( \b sub \s+ ($ident) $proto) \s+ is \s+ export ($defargs) } { add_to('EXPORT',$2,$3,$1) }gex; s{( \b our \s+ ([\$\@\%]$ident) $proto) \s+ is \s+ exported ($defargs) } { add_to('EXPORT',$2,$3,$1) }gex; s{( \b sub \s+ ($ident) $proto ) \s+ is \s+ export ($args) } { add_to('EXPORT_OK',$2,$3,$1) }gex; s{( \b our \s+ ([\$\@\%]$ident) ) \s+ is \s+ export ($args) } { add_to('EXPORT_OK',$2,$3,$1) }gex; $_ = $real_import_sub . $false_import_sub . $MANDATORY . $_; } __END__ =head1 NAME Perl6::Export - Implements the Perl 6 'is export(...)' trait =head1 SYNOPSIS # Perl 5 code... package Some::Module; use Perl6::Export; # Export &foo by default, when explicitly requested, # or when the ':ALL' export set is requested... sub foo is export(:DEFAULT) { print "phooo!"; } # Export &bar by default, when explicitly requested, # or when the ':bees', ':pubs', or ':ALL' export set is requested... # the parens after 'is export' are like the parens of a qw(...) sub bar is export(:DEFAULT :bees :pubs) { print "baaa!"; } # Export &baz when explicitly requested # or when the ':bees' or ':ALL' export set is requested... sub baz is export(:bees) { print "baassss!"; } # Always export &qux # (no matter what else is explicitly or implicitly requested) sub qux is export(:MANDATORY) { print "quuuuuuuuux!"; } IMPORT { # This block is called when the module is used (as usual), # but it is called after any export requests have been handled. # Those requests will have been stripped from its @_ argument list } =head1 DESCRIPTION Implements what I hope the Perl 6 symbol export mechanism might look like. It's very straightforward: =over =item * If you want a subroutine to be capable of being exported (when explicitly requested in the C arguments), you mark it with the C trait. =item * If you want a subroutine to be automatically exported when the module is used (without specific overriding arguments), you mark it with the C trait. =item * If you want a subroutine to be automatically exported when the module is used (even if the user specifies overriding arguments), you mark it with the C trait. =item * If the subroutine should also be exported when particular export groups are requested, you add the names of those export groups to the trait's argument list. =back That's it. =head2 C blocks Perl 6 replaces the C subroutine with an C block. It's analogous to a C or C block, except that it's executed every time the corresponding module is C'd. Perl6::Export honours either the Perl5-ish: sub import {...} or the equivalent Perl6-ish: IMPORT {...} In either case the subroutine/block is passed the argument list that was specified on the C line that loaded the corresponding module. However, any export specifications (names of subroutines or tagsets to be exported) will have already been removed from that argument list before C/C receives it. =head1 WARNING The syntax and semantics of Perl 6 is still being finalized and consequently is at any time subject to change. That means the same caveat applies to this module. =head1 DEPENDENCIES Requires Filter::Simple =head1 AUTHOR Damian Conway (damian@conway.org) =head1 BUGS AND IRRITATIONS Does not yet handle the export of variables. The author personally believes this is a feature, rather than a bug. Comments, suggestions, and patches welcome. =head1 COPYRIGHT Copyright (c) 2003, Damian Conway. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. Perl6-Export-0.009/demo/demo_export.pl000755 000765 000765 00000000201 07767535702 017201 0ustar00damian000000 000000 use Demo_Export {hash=>[1,2]}, [9..11], qw(foo :BAR qux), \"str"; print foo(), "\n"; print bar(), "\n"; print always(), "\n"; Perl6-Export-0.009/demo/Demo_Export.pm000755 000765 000765 00000000365 10127173466 017102 0ustar00damian000000 000000 package Demo_Export; use Perl6::Export; sub always is export(:MANDATORY) { "always heer" } sub foo is export(:DEFAULT) { "foo heer" } sub bar is export(:BAR) { "bar heer" } sub import { use Data::Dumper 'Dumper'; warn Dumper [ @_ ]; } 1; Perl6-Export-0.009/demo/demo_IMPORT.pl000644 000765 000765 00000000201 10127173441 016645 0ustar00damian000000 000000 use Demo_IMPORT {hash=>[1,2]}, [9..11], qw(foo :BAR qux), \"str"; print foo(), "\n"; print bar(), "\n"; print always(), "\n"; Perl6-Export-0.009/demo/Demo_IMPORT.pm000644 000765 000765 00000000362 10153232251 016610 0ustar00damian000000 000000 package Demo_IMPORT; use Perl6::Export; IMPORT { use Data::Dumper 'Dumper'; warn Dumper [ @_ ]; } sub always is export(:MANDATORY) { "always heer" } sub foo is export(:DEFAULT) { "foo heer" } sub bar is export(:BAR) { "bar heer" } 1;