On Tue, Mar 13, 2012 at 23:09, David Korn <[email protected]> wrote:

>
> The form
>        var=(...)
> is a generic compound variable assignment.  It is use for
> indexed arrays, associative arrays, and for compound variables.
> However, in some cases this is ambiguous.
>

My suggestions:

1. Compound var assignment in the `v=( )' format must be explicitly
declared with `typeset -C'
2. Var attributes like `-a', `-A' and `-C' cannot be changed unless it's
unset first. (With Bash when you try to convert a `-a' array to a `-A'
array it'll give the error message: `cannot convert indexed to associative
array'.)
3. Var attributes cannot be changed unless the old values can be migrated
to the new attributes in a natural and intuitive way
4. Var attributes like `-A' cannot be unset by `typeset +A' since that
makes no sense. (What do we expect it to do when we `typeset +A' an
associative array?)


>        var=()
> is this an empty compound variable, an empty indexed array, or
> an empty associative array.  By default, ambiguities lean towards
> selection the compound variable.
>
> Another example,
>        var=(integer x=3)
> This will be treated as a compound assignment defining x=3.  However,
> in order for this to work, the alias integer must be recognized.
> Therefore, by default, the first work is alias expanded.
>
> Therefore, it is best to explicity specify which you want.
>
>        typeset -a var=(integer x=3)
> will define an indexed array with two elements, integer and x=3.  The
> first argument will not be checked for aliases.
>        typeset -a var=([3]=abc [foo]=def)
> will define an indexed array with elements 3 and the arithmetic value
> of foo $((foo)).
>
> Use
>        typeset -A for associative array definition.
>
> Use
>        typeset -C for compound assignment.
>
>
>
> David Korn
> [email protected]
>
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to