Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Typeset with array



On Jun 19, 12:39pm, Peter Stephenson wrote:
}
} Building on the above, I've developed a Cunning Plan so that it's not
} too disruptive and is a few days rather than weeks of spare time.
} 
} It works like this.
} 
} Reserved words are added for typeset synonyms that can handle arrays:
} [...]
} The reserved words trigger variant handling in par_simple(): WC_TYPESET
} is very similar to WC_SIMPLE but there's an extra count and set of
} assignments tacked on the end.

Thanks for going on with this.  I had been toying with the idea of having
the reserved word act something like

    typeset -L2 name foo=bar array=(here there)
==> foo=bar array=(here there) builtin typeset -L2 name foo array

so that the parsing of the builtin remained unchanged, it would just need
a flag to say that the temporary values from the prefix assignment should
become the stored values of the named arguments.  This is similar to e.g.

    y=3 integer x=y

which assigns 3 to x.

However, I'm not up to speed enough on wordcode to not waste a lot of
extra time figuring out how to perform that transformation.

The other complications with any implementation are:

1. It's now possible to assign both arrays and scalars in one statement.

 - what happens for  typeset -a x="string" y=(word list)  ??

2. We don't have a distinct syntax for associative array assignment, so
this still works only for ordinary arrays.

 - ksh of course uses  h=([key] value)  to assign an associative array.



Messages sorted by: Reverse Date, Date, Thread, Author