Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[lindex] can explode List intrep

Closed / Invalid1675945fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2007-03-07 17:37:10
% set l [list a]
a

At this point $l holds a List
intrep with an objv array of 
length 1 and objv[0] is the
string value "a".

% lindex $l [lrepeat 10 0]
a

Now $l holds the same value,
but with a much larger intrep.
It's now an objv array of length 1
with objv[0] a List with objv
array of length 1 with its objv[0]
a List ....etc going 10 levels deep...
..to a objv[0] holding the string
value "a".

This isn't exactly wrong.  That is
a valid List intrep for the value,
but it's far, far from the most efficient
one available.
dkfplain2007-03-08 05:50:10
Logged In: YES 
user_id=79902
Originator: NO

That's the way it is designed to work.
Log in (anonymous is fine) to add a comment.