> U.V. Ravindra wrote:
> > When idx is explicitly declared as integer-typed
> > and argtype is an array containing strings, I
> > would expect the following to fail:
> > 
> > typeset -i idx=0
> > 
> > for idx in ${argtype[*]}; do
> >         print ${argtype[$idx]}
> > done
> 
> Erm... why should this be an error ? The array uses
> integers as _index_
> but this is independent from the datatype used by the
> _values_ of an
> array element.

Are you saying that the loop index variable gets assigned differently based on 
whether it's delcared as an integer or not?  For example, what should the 
following print?

set -A alpha "a" "b" "c" "d"
typeset -i i=0
for arg in ${alpha[*]}; do
        print $arg, ${alpha[$i]}
        ((i=i+1))
done

For me, on ksh93 (s+) the output is --
a, a
b, b
c, c
d, d

So the (non-integer) loop index is clearly being set to the *value* of each 
array parameter.

Also, shouldn't this be a syntax error (no arrays involved here) --
    typeset -i i="junk"

In ksh88, it throws an error ("junk: bad number"), but ksh93 (s+) seems to 
treat this as equivalent to with "typeset -i i=0". 

-UVR.
 
 
This message posted from opensolaris.org

Reply via email to