Overview
| Comment: | Points 4 and 5 have been completed and delivered in v16c. Regarding geometry, the annotated Tcl is now only 1.1 to 1.5 times slower than "bare" Tcl for area, perimeter, and `dedans_tous` (contains_all). 4. `X is T = v` is now compiled into a procedure. There are no longer any calls to `::tcl::unsupported::declare`, nor any lookups of the variable by its name. I also took the opportunity to eliminate two unnecessary copies: the new list of `(a, b)` now becomes the direct content of the value; an `int` or `double` shares its content rather than being copied. The command can still be used outside of a procedure or with a qualified name (such as `{::G}`), with the same behavior and messages as before. 5. Within `expr`, `$a(x)` is read directly as a number when used in a calculation (`+`, `-`, `*`, `/`, `%`, `**`) or a numerical comparison (`<`, `>`, `<=`, `>=`, `==`, `!=`). For a compact list, the value is read directly from its storage slot, without creating a view of the element or a type wrapper. In all other cases (a true array, a non-numeric field, `eq`, or a variable monitored by a read trace), the results and error messages remain unchanged. Additionally, `name = v` within a procedure now writes to the variable without requiring a name-based lookup for every assignment. Previously, every `=` operation involved such a lookup. Measurements, in nanoseconds per operation on Linux (loop overhead subtracted): operation v16b v16c A = $x 50 28 A is double = $x 313 83 A is point = $p 147 33 A is point = (1.0, 2.0) 357 196 $p(x) * 2 91 59 $c(x) * 2, element of a compact list 113 64 Geometry benchmark, annotated Tcl relative to plain Tcl (two runs, hence the ranges): calculation |v16b | v16c | compact v16b | compact v16c| ----------------| ------:| --:| ------------:| -----:| area | / 1.8 | / 1.2 to 1.5 | / 3.1| / 1.9| perimeter |/ 1.9 to 2.3 | / 1.1 to 1.4 | / 3.0| / 1.7| inside_all |/ 1.9 to 2.2 | / 1.3 to 1.4 | / 3.9| / 2.2| What remains slow: The compact form is still about 1.5 times slower than the standard form, because each `lindex` operation still creates a view of the element. `set {point}A 1.0 2.0` takes about 1.2 µs—six times longer than `A is point = (1.0, 2.0)`. I have noted this as a point for further investigation. I attempted to bypass a lookup that Tcl performs whenever an object is released, but it cannot be avoided in this case; I have reverted the change. |
|---|---|
| Timelines: | family | ancestors | descendants | both | tip-764_tcl90 |
| Files: | files | file ages | folders |
| SHA3-256: |
4a3a97279c6e3b8bba38611071e0032c |
| User & Date: | Florentis on 2026-10-25 09:50:31.643 |
| Other Links: | branch diff | manifest | tags |
Context
|
2026-10-25
| ||
| 12:21 | I have implemented the three points, delivered in v16d. The C codec now covers calculated sizes and ... check-in: 1a6fc7a4f8 user: Florentis tags: tip-764_tcl90 | |
| 09:50 | Points 4 and 5 have been completed and delivered in v16c. Regarding geometry, the annotated Tcl is n... check-in: 4a3a97279c user: Florentis tags: tip-764_tcl90 | |
| 08:04 | `lappend` under contract. When the variable is the sole holder of its value—which is the typical s... check-in: 203a80b8f5 user: Florentis tags: tip-764_tcl90 | |
Changes
Modified generic/tclAnnotObj.c
from [a930ae0c18]
to [acc8ff538b].
[diff]
Modified generic/tclCompExpr.c
from [1e692bff56]
to [bd0d196849].
[diff]
Modified generic/tclCompile.c
from [f290d24754]
to [611bc94258].
[diff]
Modified generic/tclCompile.h
from [0a38fc438f]
to [ba4b448112].
[diff]
Modified generic/tclExecute.c
from [b49bf9d825]
to [2609f6909f].
[diff]
Modified generic/tclTypePath.c
from [0f0e78a4ae]
to [a0e17b5e34].
[diff]
Modified generic/tclTypedVar.c
from [38c06566ab]
to [1a1128e0d2].
[diff]
Modified generic/tclTypes.c
from [cbc66bc0cc]
to [35d06ae1e1].
[diff]
Modified generic/tclTypes.h
from [fb8991043b]
to [edbc8369dc].
[diff]
Modified typeparse/REPRISE.md
from [9ddf957db9]
to [3bc47bd181].
[diff]
Modified typeparse/VERSION
from [d927a910ba]
to [230bc2a19b].
[diff]
Modified typeparse/doc/ANNOTATIONS.fr.md
from [926b5c677d]
to [4fbad5a5d6].
[diff]
Modified typeparse/exemples/geometrie/LISEZMOI.md
from [7bf10f80d7]
to [30748fce47].
[diff]
Modified typeparse/noyau/LISEZMOI.md
from [006bce537d]
to [5a51c117a7].
[diff]
Modified typeparse/noyau/ORDRE.txt
from [95f4d2d80f]
to [162cea6cfd].
[diff]
Added typeparse/noyau/expr-declaration-champs.patch version [266b70bd68].
Modified typeparse/tclAnnotObj.c
from [a930ae0c18]
to [acc8ff538b].
[diff]
Modified typeparse/tclTypePath.c
from [0f0e78a4ae]
to [a0e17b5e34].
[diff]
Modified typeparse/tclTypedVar.c
from [38c06566ab]
to [1a1128e0d2].
[diff]
Modified typeparse/tclTypes.c
from [cbc66bc0cc]
to [35d06ae1e1].
[diff]
Modified typeparse/tclTypes.h
from [fb8991043b]
to [edbc8369dc].
[diff]
Added typeparse/tests_tclsh/t82_declaration_compilee.out version [caded05af9].
Added typeparse/tests_tclsh/t82_declaration_compilee.tcl version [347fe20e66].