Discussion:
[ast-developers] Adding namespace name to FPATH lookup?
Cedric Blancher
2013-05-29 10:30:33 UTC
Permalink
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 <cedric.blancher at googlemail.com>
Institute Pasteur
David Korn
2013-05-29 13:36:16 UTC
Permalink
Subject: Re: [ast-developers] Adding namespace name to FPATH lookup?
--------
Post by Cedric Blancher
I'd like to use FPATH in conjunction with namespaces but noticed the
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
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 <cedric.blancher at googlemail.com>
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
dgk at research.att.com

Loading...