|
From: Joe E. <jen...@fl...> - 2004-09-25 04:06:21
|
Well, I tried switching to the form
$tree insert $parent $index ...options ...
returning an integer item ID. This didn't work out as
well as I thought it would.
Use cases where you want application-defined node IDs --
like the test suite -- really do become a lot more painful.
There's an odd asymmetry in that you *have* to name columns
but you *can't* name items. The implementation and test suite
didn't really get any simpler, it just traded one set of special
cases for another one.
This form lacks discoverability: when you're playing with
the widget from an interactive wish prompt, you end up
saying things like:
$tree insert 91 3 -text foo
Since item ids and indexes are both integers, this gets confusing.
The only real benefit is that it saves some memory [*].
So for now I've reverted to the BWidget form,
$tree insert $index $parent $id ...options...
I'm going to try this next:
$tree insert $parent $index ? -id $id ? ...options...
If "-id" isn't supplied, the widget will generate one
of the form "ixxxx", where the xes are hex digits.
--Joe English
jen...@fl...
[*] I haven't bothered measuring, but: items currently take
10 words plus a hash table entry plus a TCL_STRING_KEY; with
integer IDs the last can be changed to a TCL_ONE_WORD_KEY
which is "free" with the hash entry.
|