This is not necessarily the current version of this TIP.
| TIP: | 251 |
| Title: | Enhance the 'list' Command |
| Version: | $Revision: 1.5 $ |
| Authors: |
Brian Schmidt <contact at schmidtsrus dot net> Brian Schmidt <contact at SchmidtsRUs dot net> |
| State: | Draft |
| Type: | Project |
| Tcl-Version: | 8.5 |
| Vote: | Pending |
| Created: | Tuesday, 28 June 2005 |
This TIP proposes enhancing the existing list command to serve as a top-level command container for all the related list commands that have proliferated over time, as well as future new list-based commands.
There are numerous top-level commands for lists already. This command would centralize them, making it easier for new users to see all the related list commands. The enhanced list would be consistent with the new top-level commands chan TIP #208 and dict TIP #111, as well as the existing string and file commands.
A new command list will be added with the following syntax:
list append ;equivalent to lappend list index ;equivalent to lindex list insert ;equivalent to linsert list create ;equivalent to list list length ;equivalent to llength list range ;equivalent to lrange list replace ;equivalent to lreplace list search ;equivalent to lsearch list set ;equivalent to lset list sort ;equivalent to lsort list concat ;equivalent to concat list join ;equivalent to join
Each represents the existing command that is commented. The arguments to each would remain what the current command takes.
Note that split is not included as it ideally should be part of the string top-level command as it operates on a string and returns a list (i.e. string split would be like the current split command, see TIP #252).
The old commands could then potentially be deprecated:
lappend lindex linsert llength lrange lreplace lsearch lset lsort concat join
Incompatability with the existing list command could potentially be solved by allowing the list command *without* one of the defined options to be shorthand for the new "list create ..." command option. If the first argument to the new list command is not one of the known options then "list create ..." is assumed by default. |For example, list {my list}
would be equivalent to: list create {my list}
Thus I think the only existing scripts that would break would be those that actually utilize the list command (and have at least 2 arguments?) and that have as their first argument one of the new list command's options. Only code with lists defined exactly as follows would break:
list append ?arg... list index ?arg... list insert ?arg... list create ?arg... list length ?arg... list range ?arg... list replace ?arg... list search ?arg... list set ?arg... list sort ?arg... list concat ?arg... list join ?arg...
This document has been placed in the public domain.
This is not necessarily the current version of this TIP.