On 2005.02.25, Zoran Vasiljevic <[EMAIL PROTECTED]> wrote: > > All procs are dumped by Tcl interpreter being dumped when the > connection thread exits.
This is not true, unless you set connsperthread != 0, which we've recently discovered also has a big memory leak issue which I'm still tracking down. But, under normal operation (where connsperthread == 0), only the global variables get dumped when the conn thread exits. Tcl procs stay behind, which is why tDOM documents (which create Tcl procs) linger and "leak" memory if they're not explicitly deleted. > > Another scary side effect of this: > > > > % dom createNodeCmd elementNode string > > ::string > > > > % string is integer abcd > > called outside domNode context > > This is not scary. If you do: > > proc string {} { > return [string] > } > > it will also junk your string command. The createNodeCmd just > creates another Tcl command. If you happen to name it as some > already existent Tcl command, it is your decision. Tcl will > also not forbid you renaming existing commands, or? Perhaps what I meant was to illustrate the fact that tDOM can indeed clobber Tcl procs, any Tcl proc. It doesn't create these commands in a ::dom sub-namespace or somewhere safe -- this is just important to know. It surprised me; maybe it's surprised other people, or will surprise other people in the future. > > OK, so where did the real Tcl [string] proc go? Poof, gone. This is > > also a neat side-effect: > > > > % rename ::string {} > > % string is integer abcd > > self-referential recursion in "unknown" for command "string" > > > > Huh? Weird. > > Weird is what you're expecting. Please be aware that createNodeCmd > creates a special Tcl command which can be only used from within > the node context as the above error message correctly says: > > % string is integer abcd > called outside domNode context Well, I was expecting this: $ tclsh % proc foo {} {} % foo % rename foo {} % foo invalid command name "foo" I wasn't expecting this: self-referential recursion in "unknown" for command "foo" Is this not a bug? Why can I not safely "delete" new tDOM-created procs by renaming them to the empty string like I can with ordinary Tcl procs? > > Anyhow -- I guess this a big caveat or warning to everyone using tDOM > > with AOLserver if you're using [dom createNodeCmd] -- this way is > > fraught with peril. Use at your own risk. > > This is not a big caveat and nobody should be warned. This is > absolutely OK. You wanted to scratch/redefine the Tcl proc. I actually didn't want to. I just wanted to be able to use the "appendFromScript" feature of tDOM but my document has a node called "<string>" so I had to do: $doc createNodeCmd elementNode string I did NOT want it to clobber the Tcl ::string proc. Because of this, I could NOT use the createNodeCmd/appendFromString. I *could* have worked around it with something like this, I suppose: namespace eval ::dom { $doc createNodeCmd elementNode string $doc createNodeCmd textNode text $root appendFromScript { string {text foo} string {text bar} } } Again, I think it's important to tell folks to use a sub-namespace if they want to avoid clobbering procs with the same name. I didn't know to do this originally, and I didn't find this technique mentioned in either of these places: http://www.tdom.org/dom.html http://wiki.tcl.tk/8984 > Hence you must live with the side-effects. You kave the knife. > How you use it, this is in your responsibility. The knife is unnecessarily sharp but doesn't cut any better because of it. -- Dossy -- Dossy Shiobara mail: [EMAIL PROTECTED] Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70) -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.