From Newsgroup: comp.lang.tcl
* Petro Kazmirchuk <
vivid.tree7955@fastmail.com>
| On 19/05/2026 10:45, Colin Macleod wrote:
| > abu <
user13892@newsgrouper.org.invalid> posted:
| >
| >>
| >> Sorry if this may seem like a silly question, but what's the point of
| >> putting a trace on the reading of a variable (or an element of an array)? --<snip-snip>--
| - simpler alternative to callbacks: an object can notify about its
| $status or $new_data or $last_error through a variable that external
| code can trace with op=write and invoke a callback
--<snip-snip>--
| in short, traces are amazing, and you won't find them in any other language
However, when used excessively for control flow, traces can be a
nightmare to debug or refactor, since you don't see the command flow
from the code directly.
A simple
set foo bar
can have arbitrary side effects, depending on which module has set up
the trace, whereas with callbacks you at least see in the code that
there is something going on.
If at some point, the setting of the variable is removed for any reason,
the code follows a different path, and you might not even be aware of
that. With a callback to be removed, you at least see that you need to
check where/how the callback is used.
My re40.01
R'
--- Synchronet 3.22a-Linux NewsLink 1.2