Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to 'un-source' ?

76 views
Skip to first unread message

somede...@gmail.com

unread,
Sep 21, 2006, 4:04:51 AM9/21/06
to
If I source x.tcl, and
if x.tcl fails to get sourced (because of errors), and
if I fix the errors and try to source x.tcl again...

the shell complains about some names already existing. I'm then forced
to exit the shell, launch it again, and then source x.tcl again!

Is there a better way to re-source the corrected file in the same
session?

Thanks much.

Michael Schlenker

unread,
Sep 21, 2006, 4:21:27 AM9/21/06
to
somede...@gmail.com schrieb:

If your sourced file only creates procs and does not create objects or
other things, you can resource as often as you like. Its only if you
create objects like widgets etc. that you cannot simply re-source the file.

Michael

suchenwi

unread,
Sep 21, 2006, 4:52:42 AM9/21/06
to

Michael Schlenker schrieb:

> If your sourced file only creates procs and does not create objects or
> other things, you can resource as often as you like. Its only if you
> create objects like widgets etc. that you cannot simply re-source the file.
>

In addition, if the problem is existing widgets, you can enable a quick
re-source by adding the line, early in the script:
catch {eval destroy [winfo children .]}

Erik Leunissen

unread,
Sep 21, 2006, 5:02:57 AM9/21/06
to
In addition to Michaels suggestion:

You may use separate interpreters for each source command, while keeping
the process running.

interp create slave
slave eval source x.tcl
interp delete slave
# fix the bug if the source command returns an error, and repeat

Erik Leunissen
--
leunissen@ nl | Merge the left part of these two lines into one,
e. hccnet. | respecting a character's position in a line.

Don Porter

unread,
Sep 21, 2006, 10:21:19 AM9/21/06
to
somede...@gmail.com wrote:
> If I source x.tcl, and
> if x.tcl fails to get sourced (because of errors), and
> if I fix the errors and try to source x.tcl again...
>
> the shell complains about some names already existing.

What is the exact error message, and what command produces it?

If it is [namespace import], then update to at least Tcl 8.4.12 where
this misfeature was corrected.

--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

keithv

unread,
Sep 21, 2006, 2:00:39 PM9/21/06
to
somede...@gmail.com wrote:
> Is there a better way to re-source the corrected file in the same
> session?

http://wiki.tcl.tk/1127

The title says tkcon but it works for any console. I've been using
variants of it for almost 10 years.

Keith

0 new messages