Re: interp alias - renaming problem
- From: "Gerald W. Lester" <Gerald.Lester@xxxxxxx>
- Date: Fri, 09 Nov 2007 09:08:55 -0600
Please file a bug report with the script you posted.
Now, to get everything to work for you -- remove the rename inside of the trace procedure (there is no need for it and this is what is causing your crashes). Lastly, you do no have to delete the alias and then redefine it -- just redefine it.
neuronstorm@xxxxxxxxx wrote:
On Nov 8, 3:01 pm, "Gerald W. Lester" <Gerald.Les...@xxxxxxx> wrote:neuronst...@xxxxxxxxx wrote:Hi,Read the man/help page on the trace command. Pay particular attention to
When using 'interp alias', is there any way of recreating a particular
alias without destroying the associated command? or.. 'updating' an
alias using the returned token?
e.g
proc spud {args} {return spuddata-$args}
interp alias {} a1 {} spud data1
rename a1 somewhere_I_dont_know_about
(The command a1 has possibly been renamed somewhere - outside of my
control.
The alias token still exists as 'a1' though.)
Now I'd like to update the alias (whose name is now divorced from the
command name)
I was hoping to just do:
interp alias {} a1 {} spud newdata
but this simply creates a new alias ::a1 with a new command a1
I can't just delete the alias a1 and recreate it - because I have no
idea where the corresponding command is supposed to go.
Any workarounds?
the rename and delete options.
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+- Hide quoted text -
- Show quoted text -
Thanks - This means maintaining a separate datastructure upon renaming
to point to the actual command.
The whole idea of using interp alias was to keep the required info
built into the comand.
If I have to go looking stuff up somewhere else anyway it rather
defeats the purpose.
I tried storing the destination command in the interp alias data
itself.. but I'm not sure this can be done from within a
'trace add command $cmd rename' procedure.
Actually it crashes my Tclsh.. with
'malformed bucket chain in Tcl_DeleteHashEntry'
Tested and crashed the following script
in tclsh 8.5a7, tclkitsh 8.5b1 & tclkitsh8.4.16 on windows
tclsh8.5a7 on FreeBSD
proc spud {args} {return spuddata-$args}
interp alias {} a1 {} spud data1
trace add command a1 rename [list handle_rename a1]
proc handle_rename {alias args} {
lassign $args oldcmd newcmd _rename
#remove existing alias
interp alias {} $alias {}
#recreate alias with desired token
interp alias {} $alias {} spud "somedata,$newcmd"
#rename the command to the right location leaving alias token intact.
rename $oldcmd $newcmd
}
rename a1 blah
(the crash occurs with or without the 2nd interp alias call, but I
only see the malformed bucket msg with both calls in place)
Cheers,
Julian
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.
- Follow-Ups:
- Re: interp alias - renaming problem
- From: neuronstorm@xxxxxxxxx
- Re: interp alias - renaming problem
- References:
- interp alias - renaming problem
- From: neuronstorm@xxxxxxxxx
- Re: interp alias - renaming problem
- From: Gerald W. Lester
- Re: interp alias - renaming problem
- From: neuronstorm@xxxxxxxxx
- interp alias - renaming problem
- Prev by Date: Re: Tcl on slashdot...
- Next by Date: Re: Tcl on slashdot...
- Previous by thread: Re: interp alias - renaming problem
- Next by thread: Re: interp alias - renaming problem
- Index(es):
Relevant Pages
|