Skip to content
Tcl Source Code View Ticket
Login

View Ticket

linsert man page end indexing inconsistency

Closed / Fixed3045123fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 16 years ago
Descriptionplain2010-08-15 01:33:42
Copied from http://wiki.tcl.tk/1485 :

According to the man page, "[linsert] produces a new list from list by inserting all of the element arguments just before the index’th element of list." When doing end-relative indexing, this definition doesn't match the actual behavior. To explain how index is interpreted, the [linsert] man page refers to the [string index] man page, which says that end indicates the last element. From this I expect that [linsert {0 1 2} end x] will return {0 1 x 2}, the result of inserting x just before the end element of the list, which is 2. However, it actually returns {0 1 2 x}, so when doing end-relative indexing it inserts the new elements just after  the indicated index. An alternative, more plausible explanation is that it inserts the new elements such that the first or last of the inserted elements will occupy the indicated index.

Suggest updating the documentation to resolve this inconsistency.
andygothplain2010-08-15 08:35:55
Oops, make that http://wiki.tcl.tk/1482 .
dkfplain2010-08-21 23:58:26
allow_comments - 1
Log in (anonymous is fine) to add a comment.