On Fri, Jan 15, 2010 at 03:58:47PM -0500, David Korn wrote:
> > Also in t+, there are problems with discipline functions:
> > 
> > $ ksh -c 'function x.get { print "Subscript: ${.sh.subscript}"; }; : 
> > ${x[1]}; print Done'
> > Done
> > $ ksh -c 'typeset -A x; function x.get { print "Subscript: 
> > ${.sh.subscript}"; }; : ${x[1]}; print Done'
> > Memory fault
> I ran this with the current release and did not get a core dump.

Thanks, I've built 2009-12-24 and it resolved the core dump problem.  But, I
still get the earlier problem.  In ksh93r, the get discipline function is
invoked for all references to values in indexed arrays:

$ ksh93r -c 'function x.get { print "Subscript: ${.sh.subscript}"; }; x[2]=; : 
${x[1]} ${x[2]}'
Subscript: 1
Subscript: 2

In ksh93t+, including the beta, it is still invoked for all references to
values in associative arrays:

$ ksh93 -c 'typeset -A x; function x.get { print "Subscript: ${.sh.subscript}"; 
}; x[2]=; : ${x[1]} ${x[2]}'
Subscript: 1
Subscript: 2

but is invoked for references to the values of indexed arrays only if an index
has been set:

$ ksh93 -c 'function x.get { print "Subscript: ${.sh.subscript}"; }; x[2]=; : 
${x[1]} ${x[2]}'
Subscript: 2

This foils an attempt to create a function that provides a value for indexes
that aren't set.  In some (though not all) cases it can be worked around by
using an associative array, but it is unexpected behavior.

        John
-- 
John DuBois     [email protected]   KC6QKZ/AE
I wish to God these calculations had been executed by steam. - Charles Babbage
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to