develooper Front page | perl.perl6.language | Postings from February 2001

Re: Really auto autoloaded modules

Thread Previous | Thread Next
From:
Damian Conway
Date:
February 2, 2001 15:57
Subject:
Re: Really auto autoloaded modules
Message ID:
200102022357.KAA20939@indy05.csse.monash.edu.au
 
   > Where should this info be maintained? In a module in @INC (sort of like
   > CPAN/MyConfig.pm)? Or in a special file that's only written to via a
   > module install? Or in a block atop each module that's yanked out via
   > MakeMaker? Or???

The parser needs to have it in a standard system-wide place.

I wasn't actually proposing it as a replacement mechanism for Exporter,
but if that standard configuration file included the line:

	autouse STD::autouse { 1 }

then I suppose any other module could replace:

	@EXPORT = qw( foo bar );

with:

	autouse foo {1}
	autouse bar {1}

Which implies we might make use of RFC 128's variadic parameters feature and
the proposed multi-valued C<foreach> to implement autouse as:

	sub autouse ( ("", &) : repeat {
	    foreach my ($qualified_name, $condition) (@_) {
                my ($package, $name) = $qualified_name =~ m/(.*)::(.*)/;
                push @{$autousage{$name}},
                        { package => $package, condition => $condition };
	    }
        }	

and treat ourselves to:

	autouse foo {1}, bar {1};

I suppose this also implies a C<requested> subroutine (C<autouse>'d,
of course :-) within modules -- so that one can replace:

	@EXPORT_OK = qw( only by request );

with:

	autouse only    {requested},
		by      {requested},
		request {requested},
	;

Hmmmm. Tidy, but too tedious perhaps?

Damian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About