View · Search · Index
No registered users in community xowiki
in last 10 minutes

[Xotcl] Xotcl autonames

From: Michael Schlenker <>
Date: Thu, 16 Feb 2006 20:16:24 +0100

Hi all,

i used the autoname instproc to create object instance names and was
surprised that autonames can conflict.

Basically i have two objects of the same class, which both get rows from
a database and create objects for each row:

Something like this:

PM instproc dbRead {program_id} {
 # some things ommited
my set tracks ""
set tracks [::MOD select list program_tracks {track_id} program_id
foreach t $tracks {
        set m [::wings::model::TrackModel [my autoname TrackM]]
        $m dbRead $t
        my lappend tracks $m

After i create two objects of this class, i see the TrackM autonames
used by both objects starting from 0, basically the second object
overwrites my autonamed objects from the first one.

I fixed it by adding:

my instproc autoname {args} {
set name [next]
while {[llength [info commands $name]]} {set name [next]}
return $name

to the class, but wondered if this is expected behaviour of autonames.