Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2016-08-14
12:22 • Ticket [0ec75b9a08] Debug display on shimmering status still Open with 8 oth... artifact: e385e0c68a user: ferrieux
10:05 • Ticket [0ec75b9a08]: 3 changes artifact: aee015ee34 user: anonymous
09:52 • Ticket [0ec75b9a08]: 3 changes artifact: cd6d5d56bc user: anonymous
2016-08-13
09:35 • Ticket [0ec75b9a08]: 3 changes artifact: 8d2d29674a user: ferrieux
09:05 • Ticket [0ec75b9a08]: 3 changes artifact: 8845f38a88 user: ferrieux
08:08 • New ticket [0ec75b9a08]. artifact: f8ea6e8ceb user: anonymous

Debug display on shimmering

Open0ec75b9a080ccc656d790703216fa64c6bdf7eedCreated 10 years agoUpdated 10 years ago
Descriptionplain2016-08-13 08:08:46
Command ::use_strict

Each time a variable is shimmered, the interpreter launch an exception. Similar idea of "use strict" from javascript.

This can prevents bad design patterns or accidental shimmering.
ferrieuxplain2016-08-13 09:05:59
Shimmering is in aspect of a *value*'s life, not a variable.
This distinction matters, because the value can be shared or copied, with different outcomes on whatever behavior we try to attach to it.

Moreover, calling an arbitrary command from deep within the interpreter (at the time the shimmering is decided) raises many implementation issues.

Last, letting the script level *act* on the internal status of values simply violates the EIAS principle (Everything Is A String) and leads to varied impredictable situtations.

Note we do violate it a bit already with the explicit introspection in ::tcl::unsupported::representation, but the way it is serialized tries to discourage decision-making.

In the same vein, a "for-your-eyes-only" variant that (e.g.) writes to stderr when shimmering or Dup'ing (to address the branching history of a value) an intrep, could be useful, and not more dangerous.

Deal ?
ferrieuxplain2016-08-13 09:35:21
Also, be warned of two points:

(1) Even in its mild, "display-only" form, the feature would have a non-negligible perf impact.

Indeed, binary compatibility with extensions precludes adding any field directly to values or internal reps, so the "you're being watched" flag must be implemented as a pointer hash, with associated check on each Dup or Free. This means that only a few values could be watched at any given time, and also that the feature would likely be non-mainstream (macro-controlled).

(2) Displaying any meaningful context for the Dup or Free operation would be extremely hard. The setFromAnyProc of each obj type tends to call TclFreeIntRep on the old type without any kind of politeness like "I'm shimmering to Y".

Hmm. That's a hell of a set of restrictions, right ?
anonymousplain2016-08-14 09:52:11
Using this feature is possible to create some optimizations in the interpreter. It's only an idea.
anonymousplain2016-08-14 10:05:20
Another idea is to use a debug flag to print to stderr when some shimmering happens.

For example by default the variable ::warn_shimmering is set to 0. But if this variable is set to 1 (or another true value)

   set ::warn_shimmering 1

then the interpreter print to stderr a warning.

It's similar to your idea.
ferrieuxplain2016-08-14 12:22:57
If the only incentive is to help optimize "the interpreter", then that's no news, and mimicking another language's implementation is not the best path to it (see my remarks about the lack of context for Dup and Free).

Accordingly, I'm changing the title to something that's clearer to core developers, the category to the proper one, and also downgrading this ticket to lowest priority, since it's a long-term goal (for Tcl9) that would likely be more interesting *after* current work in progress on obj types is completed (more than 1 intrep ; direct conversions between "friend" types, etc.)
Log in (anonymous is fine) to add a comment.