Hi!

----

While writing an example for typeset -m I found an issue that moving a
compound variable (objstack_t.st[...].obj in this case) from an
compound variable array into a function-local compound variable does
not work.
For example:
-- snip --
# stack of objects
typeset -T objstack_t=(
        compound -a st
        integer st_n=0

        # push an object
        # argument is the name of a variable which will
        # be moved into the stack space
        function pushobj
        {
                nameref obj=$1
                typeset -m "_.st[$((_.st_n++))].obj=obj"
        }

        # pop an object and return it to the location
        # specified by the variable name passed in
        function popobj
        {
                nameref obj=$1
                (( --_.st_n ))
                typeset -m "obj=_.st[$((_.st_n))].obj"
                #unset _.st[$((_.st_n))]
        }
)


function main
{
        compound c
        objstack_t c.ost
        
        compound foo=( integer val=5 )
#       float foo=1.23

        # push object "foo"
        c.ost.pushobj foo

        # retrive object "foo" and store it as "res.a"
        compound res
        c.ost.popobj res.a
        print -v res
        return 0
}

set -o nounset
main
exit $?
-- snip --
... should AFAK print
(
    a=(
        integer val=5
    )
)
-- snip --
... but ast-ksh.2013-04-09 prints this:
-- snip --
(
)
-- snip --
(replacing the compound variable "foo" in the example above by a float
variable "foo" works... except that it shows signs of the bug
described in 
http://lists.research.att.com/pipermail/ast-developers/2013q2/002465.html
("Moving float/integer/typeset -M into compound via typeset -m looses
attributes..."))

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to