TIP #45: EMPTY INDEX LISTS FOR [LINDEX] AND [LSET] ==================================================== Version: $Revision: 1.9 $ Author: Kevin Kenny Don Porter State: Final Type: Project Tcl-Version: 8.4b1 Vote: Done Created: Wednesday, 18 July 2001 URL: https://tip.tcl-lang.org45.html Discussions-To: news:comp.lang.tcl mailto:kennykb@acm.org Post-History: ------------------------------------------------------------------------- ABSTRACT ========== TIP's #22 and #33 contain an oversight in specifying the behavior of the multi-argument forms of /lset/ and /lindex/ when an empty index list is specified. The intended behavior is that an empty list of indices designates the entire list. RATIONALE =========== In the discussion of [TIP #33] ([]), Jim Ingham pointed out that the list of indices presented to the multi-argument forms of /lindex/ and /lset/ is analogous to a database cursor. This cursor is conceptually navigating a tree structure; the command: lindex $list {1 2 3} means, "extract the sublist at index 1 in $list, the sublist at index 2 in that list, and the element at index 3 in that list". When implementing this functionality, the author of this TIP realized that [TIP #22] and [TIP #33] provide no way to address the root of the tree -- the entire list being manipulated. An empty list of indices is a convenient means of specifying the root. SPECIFICATION =============== 1. The specification of /lindex/ in [TIP #22] shall be amended so that the forms: lindex list and lindex list {} will return the value of the entire list. The /list/ parameter is not required to be a well-formed Tcl list when this form is used. 2. The specification of /lset/ in [TIP #33] shall be amended so that the forms: lset var value and lset var {} value will simply store the supplied value into the variable named /var/. Neither the old nor the new value of /var/ is required to be a well-formed Tcl list when this form is used. The return value of the operation, as with all other uses of /lset/, is the new value of /var/. REFERENCE IMPLEMENTATION ========================== Work progresses on implementing this functionality; the currently committed version is on SourceForge in the branch labeled, /kennykb-tcl-22-33/. DISCUSSION ============ Since this proposed change introduces syntax that is expressly forbidden in [TIP #22] and [TIP #33], it does not have any impact on backward compatibility. For the same reason, the author thought it unwise to proceed with its implementation without a vote of the TCT. SEE ALSO ========== [TIP #22], [TIP #33]. COPYRIGHT =========== This document has been placed in the public domain. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows