2026-10-24 13:29:48
— part of check-in
[4269a60689]
on branch tip-764_tcl90
— Point 2 is complete and documented. All that remains is to wait for Valgrind and the full Tcl test suite—which are currently running in the background (taking about 40 minutes)—before sending the zip file.
Previous behavior:
Each read operation `$a(x)` would look up the field by its name and follow general path-resolution rules.
Subsequently, `expr` would receive a typed value, causing it to exit its optimized "fast path" for numeric operations.
Changes:
Field caching: The index of a compiled read (the `x` in `$a(x)`) now stores the previously encountered type and the field's location. Subsequent reads involving the same type proceed directly to the element. Sums, variable links (`var`), and `list.any` continue to use the general path-resolution mechanism.
Typed numbers in `expr`: An operand typed as `int` or `double` is now read directly from its underlying content. This is implemented via a new core patch, `expr-nombres-types.patch` (in `tclExecute.c`). The result is never written back into the operand; thus, a variable such as `{double}d` remains unchanged—a fact verified by the test suite. Measurements (10,000 points):
Bare Tcl v15s current
reading $a(x) within expr 0.05 µs (lindex) ≈ 0.52 µs 0.14 µs
foreach a $P {set s [expr {$s + $a(x)}]} 0.64 ms 5.2 ms 1.5 ms
Geometry, performance gap relative to the baseline (bare Tcl):
calculation v15s v15u v15v
area / 3.4 / 2.2 / 1.8
perimeter / 2.7 / 1.9 / 2.1
bounding box / 6.7 / 3.7 / 3.0
inside_all / 3.6 / 2.6 / 2.1
Bézier / 2.7 / 2.4 / 2.4
The perimeter figure shows a slight regression, from / 1.9 to / 2.1. This is likely measurement noise; this calculation primarily involves procedure calls.
What remains during the read operation is the creation and subsequent release of the field's typed value. Eliminating this would require the `expr` command to know—at compile time—that it only requires a numeric value, which is a separate, more complex undertaking.
Verified so far:
All 54 tests pass, including the new `t76_lecture_champ` (field read) test, which produces the same output as it did before the change.
Results are identical whether the compact form is used or not.
(user:
Florentis,
size: 351)
[annotate]
[blame][check-ins using]
2026-11-27 09:47:31
— part of check-in
[eacc36058b]
on branch tip-764_tcl90
—
v17z
Review of sum type notation.
- A variant of a sum is metadata, it must not appeat into the value :
If there is ambiguity to choose a variant of a sum, it must be an error.
- New commands to request variants of a sum type, or of a litteral sum :
type variant $v ?NAME? : empty for a litteral ; NAME select the variant of the value.
type variant -of T ?NAME?
type literal -of T ;
type is {sum?}T
type is {enum?}T
- New command to compare the type of a value :
type eq T1 T2 : true is types T1 and T2 are equal
type include T1 T2 : true if type T2 is included into T1
- New type 'num'
(user:
Florentis,
size: 351)
[annotate]
[blame][check-ins using]