Wendy Lin
2013-07-30 08:39:51 UTC
cc: wendlin1974 at gmail.com
Subject: Re: [ast-users] ksh -c 'namespace a.c.b { integer i=5 ; } ; ' => a.c.b: is not an identifier?
Subject: Re: [ast-users] ksh -c 'namespace a.c.b { integer i=5 ; } ; ' => a.c.b: is not an identifier?
How do I create a nested namespace?
-- snip --
diff -r -u original/src/cmd/ksh93/sh/xec.c
build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c
--- src/cmd/ksh93/sh/xec.c 2013-07-25 02:37:26.000000000 +0200
+++ src/cmd/ksh93/sh/xec.c 2013-07-28 05:36:31.827214685 +0200
@@ -2710,8 +2710,10 @@
Namval_t *oldnspace = shp->namespace;
int offset = stktell(stkp);
int flag=NV_NOASSIGN|NV_NOARRAY|NV_VARNAME;
+#if 0
if(cp)
errormsg(SH_DICT,ERROR_exit(1),e_ident,fname);
+#endif
sfputc(stkp,'.');
sfputr(stkp,fname,0);
np =
nv_open(stkptr(stkp,offset),shp->var_tree,flag);
-- snip --
-- snip --
# the next three lines are placeholders for the parent namespaces
namespace com { true ; }
namespace com.att { true ; }
namespace com.att.research { true ; }
# test namespace for AT&T Research
namespace com.att.research.hello
{
function print_hello
{
print 'Hello World'
}
}
# do somthing
.com.att.research.hello.print_hello
-- snip --
IMO this would finally a major step forward towards a common
function/type library where each party has it's own namespace which is
organised like DNA (see java why this is a good idea)
- At some point namerefs to functions, e.g. typeset -f -n would be
usefull... e.g. nameref -f hello=.com.att.research.hello.print_hello #
would map the function .com.att.research.hello.print_hello to the
short name "hello" without requiring a wrapper function (saving
execution name)
$ ksh -c 'namespace a { true ; } ; namespace a.sp1 { integer i=5 ;
function inc { let i++ ; } ; } ; print ${.a.sp1.i} ; .a.sp1.inc ;
print ${.a.sp1.i} ' # print $'5\n5' but should print $'5\n6'
Comments/feedback/rants/etc. wecome...
-- snip --diff -r -u original/src/cmd/ksh93/sh/xec.c
build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c
--- src/cmd/ksh93/sh/xec.c 2013-07-25 02:37:26.000000000 +0200
+++ src/cmd/ksh93/sh/xec.c 2013-07-28 05:36:31.827214685 +0200
@@ -2710,8 +2710,10 @@
Namval_t *oldnspace = shp->namespace;
int offset = stktell(stkp);
int flag=NV_NOASSIGN|NV_NOARRAY|NV_VARNAME;
+#if 0
if(cp)
errormsg(SH_DICT,ERROR_exit(1),e_ident,fname);
+#endif
sfputc(stkp,'.');
sfputr(stkp,fname,0);
np =
nv_open(stkptr(stkp,offset),shp->var_tree,flag);
-- snip --
-- snip --
# the next three lines are placeholders for the parent namespaces
namespace com { true ; }
namespace com.att { true ; }
namespace com.att.research { true ; }
# test namespace for AT&T Research
namespace com.att.research.hello
{
function print_hello
{
print 'Hello World'
}
}
# do somthing
.com.att.research.hello.print_hello
-- snip --
IMO this would finally a major step forward towards a common
function/type library where each party has it's own namespace which is
organised like DNA (see java why this is a good idea)
- At some point namerefs to functions, e.g. typeset -f -n would be
usefull... e.g. nameref -f hello=.com.att.research.hello.print_hello #
would map the function .com.att.research.hello.print_hello to the
short name "hello" without requiring a wrapper function (saving
execution name)
$ ksh -c 'namespace a { true ; } ; namespace a.sp1 { integer i=5 ;
function inc { let i++ ; } ; } ; print ${.a.sp1.i} ; .a.sp1.inc ;
print ${.a.sp1.i} ' # print $'5\n5' but should print $'5\n6'
Comments/feedback/rants/etc. wecome...
$ ksh -o nounset -c 'namespace org { true ; } ; namespace org.nrubsig
{ true ; } ; namespace org.nrubsig.util { integer i=5 ; typeset -T
x_t=( integer i ; ) ; } '
./arch/linux.i386-64/bin/ksh: .sh.type.org.nrubsig.util: no parent
-- snip --
2. The "enum" builtin lists a enumeration declared in a nested
namespace without namespace prefix (AFAIK it shouldn't be printed at
all because the call to "enum" to list all enumerations is done
-- snip --
$ ksh -o nounset -c 'namespace org { true ; } ; namespace org.nrubsig
{ true ; } ; namespace org.nrubsig.util { integer i=5 ; enum x=( 1 2 3
) ; } ; enum'
enum _Bool=(
false
true
)
enum x=(
1
2
3
)
-- snip --
3. Accessing integer variables in (( )) within the namespace dosn't
work (already reported... but listing it here since it's a nasty bug
-- snip --
$ ksh -o nounset -c 'namespace a { true ; } ; namespace a.sp1 {
integer i=5 ; function inc { (( i++ )) } ; } ; print ${.a.sp1.i} ;
.a.sp1.inc ; print ${.a.sp1.i} '
5
./arch/linux.i386-64/bin/ksh: .a.sp1.inc: line 1: i: parameter not set
5
-- snip --
... this should print $'5\n6' ...
that we can test them. Thank you
Wendy