develooper Front page | perl.perl5.porters | Postings from October 2003

arg-list scope and function resolution.

Thread Next
Jim Cromie
October 16, 2003 23:36
arg-list scope and function resolution.
Message ID:


Is it completely hairbrained to consider adding a new 'arg-list-scope',

which inside the arg-list of a function/method call, adds that namespace
(but only for that immediate context) to those that will be searched to 
resolve the function-name ?

one place this might be helpful is using POSIX constants as arguments to 
POSIX functions
it seems too Java-ish to have to say;

         use POSIX();
         $fd = POSIX::open($path, POSIX::O_CREAT | POSIX::O_EXCL | 

now, we dont HAVE to do that :-), but folks who worry about symbol table 
growth do.

It seems theres enough context inside the arglist to: skip the symbol 
import, save the keystrokes,
do so at compile time (at least for above, where its not a method-call), 
save the world, and knock off early.

It would be nice to specify this either on a per-function basis, or 
perhaps on an entire class.
The former sounds like a method attribute  (since Ive already asked for 
compile-time :-)

sub POSIX::open
    : uses_helpers

    : constant, helper

I cant think of a good pragma name to specify this self-preferential 
so Ill just WAG:

use self_preference qw ( open close );
use self_help qw ( O_CREATE O_EXCL );
use self_help qw ( :fcntl_h :errno_h );

The mapping of O_WRONLY to POSIX::O_WRONLY should only be done if O_WRONLY
isnt already imported in,  least suprise dictates that only undefined 
symbols should be
resolved this way.

Taking this further, the uses_helpers attribute could accept args, which 
would name the helper-class
(aka interface) where the helper functions would be found. 

... but I have no idea how this might be implemented,
so I hope this appeals to someone with the tuits and the clues.

Id happily accept a few clues myself, but I wager the patch would be 
less work
than explaining it to me.. :-O

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About