Re: Silent overriding of the command?
From: Victor Wagner (vitus_at_45.free.net)
Date: 11/13/03
- Next message: TingChong: "Re: get a response from user"
- Previous message: Bryan Oakley: "Re: Silent overriding of the command?"
- In reply to: Cameron Laird: "Re: Silent overriding of the command?"
- Next in thread: lvirden_at_yahoo.com: "Re: Silent overriding of the command?"
- Reply: lvirden_at_yahoo.com: "Re: Silent overriding of the command?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 13 Nov 2003 15:10:02 +0000 (UTC)
Cameron Laird <claird@lairds.com> wrote:
: I know Victor's experienced with Tcl, and I wonder if there's some
: deeper story afoot here. I've certainly heard others mention re-
Story is just simple:
Some novice user was caught in this trap - he wrote procedure named
"scan" in some Tk script and thus destroyed behavoir of Up/Down arrows
in text widget.
He wrote in Russian Tcl mailing list very complete report of this
problem.
It took me some time to track down cause of error. And this with my
eight years of Tcl experience and some more with full-time work in
softwore engineering.
Earlier today I've discovered that some new commands are available in Tk
8.4 (I forget to upgrade tk8.3-doc package to tk8.4-doc) also with
names which are quite easy to override, such as labelframe.
Now, I've just thought of how easy it is to not remember, or not know
that there is some core command with certain name, which is used in
standard library procedures. There are lot of them in the Tk and they
are quite complex.
You just call your procedure some obvois name, like scan or format, or
seek, and behold - behavoir of standard Tk widgets is broken.
Perl folk give some more thought to this problem. So they provided magic
namespace CORE::, which allows to call standard builtin command even
if user desired to override it in root namespace .
In Tcl such approach possibly would clash with interp alias mechanism,
which is essential for safe interpreters. But something simular is
desirable.
If people want to override behavoir of library routines, they would
override upper level, documented functions, or, in case of Tk, use bind
scripts.
So, it wouldn't harm anybody if internal calls from library scripts
would be explicitely made to core commands.
: I suspect if I spent time, I could find "prior art" for a modified
: [proc] that refuses to overwrite existing commands. It should only
: take a dozen lines, in any case.
Of course, Tcl makes it easy to protect from overriding commands in your
application. If I'd allow user scripting, I probably would use slave
interpreter for it.
But package authors are helpless in this situation. Command can be
overriden even before package, which depends on it, is loaded.
--
I think it's a new feature. Don't tell anyone it was an accident. :-)
-- Larry Wall on s/foo/bar/eieio in <10911@jpl-devvax.JPL.NASA.GOV>
- Next message: TingChong: "Re: get a response from user"
- Previous message: Bryan Oakley: "Re: Silent overriding of the command?"
- In reply to: Cameron Laird: "Re: Silent overriding of the command?"
- Next in thread: lvirden_at_yahoo.com: "Re: Silent overriding of the command?"
- Reply: lvirden_at_yahoo.com: "Re: Silent overriding of the command?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|