Subject: Re: [ast-developers] Adding namespace name to FPATH lookup?
--------

> I'd like to use FPATH in conjunction with namespaces but noticed the
> namespaces are not used to locate loadable functions:
> strace ~/bin/ksh -c 'PATH=/usr/bin ; FPATH=/usr/lib64/mykshlib ;
> namespace aa.bb.cc { hellox ; } ; ' 2>&1 | fgrep mykshlib
> stat("/usr/lib64/mykshlib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> open("/usr/lib64/mykshlib/hellox", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
> such file or directory)
> open("/usr/lib64/mykshlib/hellox", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
> such file or directory)
> 
> I would like that the namespace identifier is used as directory name,
> with any '.' characters replaced by '/'. The strace output would look
> similar to this example:
> strace ~/bin/ksh -c 'PATH=/usr/bin ; FPATH=/usr/lib64/mykshlib ;
> namespace aa.bb.cc { hellox ; } ; ' 2>&1 | fgrep mykshlib
> stat("/usr/lib64/mykshlib/aa/bb/cc/", {st_mode=S_IFDIR|0755,
> st_size=4096, ...}) = 0
> open("/usr/lib64/mykshlib/aa/bb/cc/hellox", O_RDONLY|O_CLOEXEC) = -1
> ENOENT (No such file or directory)
> open("/usr/lib64/mykshlib/aa/bb/cc/hellox", O_RDONLY|O_CLOEXEC) = -1
> ENOENT (No such file or directory)
> stat("/usr/lib64/mykshlib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> open("/usr/lib64/mykshlib/hellox", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
> such file or directory)
> open("/usr/lib64/mykshlib/hellox", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
> such file or directory)
> 
> The goal is to allow larger function libraries to be used.
> 
> Ced
> -- 
> Cedric Blancher <[email protected]>
> Institute Pasteur

The way to use namespaces with loadable functions is to place the
function definition in the namespace you want,
cat $FPATH/xyz
        namepace foo
        {
                function xyz
                {
                }
        }
        namespace bar
        {
                function xyz
                {
                }
        }

When xyz is referenced from any namespace, it will load functions named
xyz from any namespace.

If you want to keep the functions in a hierarchy, then you can
do so by putting the logic into the xyz function file.


David Korn
[email protected]
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to