tsv lset
Sets one element of a list in a shared array.
tsv::lset ARRAY ELEMENT INDEX ?INDEX ...? VALUE
Description
The command tsv::lset sets the element at INDEX of the list in the element to VALUE, as lset does, and gives the new list. Two or more INDEX words are a path into nested lists. An index past the end is an error.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| ARRAY | array name | required | The name of the shared array. |
| ELEMENT | string | required | The name of the element. |
| INDEX | index | required | An index, or one step of a path. |
| VALUE | string | required | The new element. |
Returns
The new list.
Examples
% tsv::set l x {a b c}
> tsv::lset l x 0 Y
Y b c
% tsv::set n x {{a b} {c d}}
> tsv::lset n x 1 0 Q
{a b} {Q d}
Errors
# Tcl 9.1 only
% tsv::set l x {a b c}
> tsv::lset l x 9 Y
index "9" out of range
-errorcode TCL VALUE INDEX OUTOFRANGE
# Tcl 8.6 only
% tsv::set l x {a b c}
> tsv::lset l x 9 Y
list index out of range
-errorcode TCL OPERATION LSET BADINDEX
% tsv::lset nothere x 0 a
"nothere" is not a thread shared array
-errorcode NONE
Tcl 8.6 and Tcl 9.1
- The message of an index past the end is the message of
lsetof the release.
Facts
- Capability
thread. A new interpreter does not have it until the host turns it on.- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1