I got this...
On Fri, 17 Jan 2003, Dossy wrote:
> Generally, when I find myself needing things like, say, a list of
> arrays, in Tcl, they tend to be design smells. It's the "I can write
> Perl in any language!" syndrome.
...and this:
On Fri, 17 Jan 2003, Brett Schwarz wrote:
> I am just curious, can you give an example of something that is giving
> you a hard time?
OK. When I'm building a substantial app, there's a lot of data floating
around. When I'm pulling data out of the database, I often will have
something where I have a brand that has customers that have orders that
have line items, and I want to store those. I think managing complexity
by abstracting the data is good programming practice. When I've done this
in the 7.x-era Tcl, I've done it by using an array with specially-crafted
indices, and using wrapper functions so I can do things like "set orders
[customers orders $customer_id]" and get a list of order IDs. But I find
my array implementations to be kludgy (more a defect of the class of
solutions, rather than the particular implementation), so I'm always
looking for something better. Also, I want to do a lot of the persistence
work only once, so I want routines that pull records from the database
based on criteria I specify, and carry them in a cache, and then notice
when I modify the records so I can then do a "cache commit" to do all the
updates. And I want to write those routines to be generic, so I don't
have to rewrite them again for each database table. (I really did this for
one project, and it mostly worked, but it was fragile.) Recently, I've
gotten to do some work in WebObjects, which has a lot of this done, but in
Java, and I still find value in the Tcl/AOLserver approach, so I'm looking
to apply some of these ideas in Tcl, but the data structures as I knew
them felt too constraining. I think the 8.4 list implementation is a step
in the right direction; I don't know if it's really what I'm looking for,
but I think it will be cleaner (and probably faster, given the
implementation differences between arrays and lists) than the array
implementation I've done.
Pete.