Is this how [concat] really works?
From: R. T. Wurth (rwurth_at_att.net)
Date: 10/30/03
- Next message: Luciano ES: "Diamonds are forever. Exec problems too."
- Previous message: cfk: "Re: dynamic string in a grid box"
- Next in thread: Donal K. Fellows: "Re: Is this how [concat] really works?"
- Reply: Donal K. Fellows: "Re: Is this how [concat] really works?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Oct 2003 02:50:53 GMT
The man page for concat (in 8.4.1) describes its operation in terms
of strings ( ... joins each of its arguments together with spaces
after trimming leading and trailing spaces from each of them). It
states that this has the effect of concatenating lists. I read it
as implying that if the arguments have internal TclObj
representations that are pure lists with no currently-valid string
representation, [concat] will extract the string representations,
(thereby invalidating the list purity of their TclObj structures)
and produce, using string operations, a result that, while
representing a valid list, has only a string representation in its
TclObj.
Is this description still a true description of the internals of
concat in recent versions of Tcl? Or is this man page an unupdated
remnant of a former (pre-TclObj) version of the interpreter? It
would seem to me that by now this command should be producing a pure
list when all its arguments are pure lists, thus eliminating the
need to reconstruct the string representations of its arguments.
I've been scouring the man pages for alternatives that preserve the
purity of list arguments' TclObj structures and produce a pure list
result. I found no direct command, but I did come up with:
set result [eval [list linsert $list1 end] $list2]
But is this really gaining me anything? The [eval] command is said
to concatenate its argument lists. If this is done by invoking an
internal form of concat, it would seem that it is destroying the
purity of at least $list2. I suspect $list1 is sufficiently
isolated that it survives intact as a pure list.
So, is there a good way to concatenate lists that produces a pure
list result and leaves pure list arguments undisturbed?
-- Rich Wurth / Rumson, NJ USA / rwurth@att.net
- Next message: Luciano ES: "Diamonds are forever. Exec problems too."
- Previous message: cfk: "Re: dynamic string in a grid box"
- Next in thread: Donal K. Fellows: "Re: Is this how [concat] really works?"
- Reply: Donal K. Fellows: "Re: Is this how [concat] really works?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|