Artifact 5b2477a7fa8f78030c4b52d30baaa74aa6f925944a95c2a6d99033adfd24df2b:
- File typeparse/tests_tclsh/t89_set_type_rapide.tcl — part of check-in [2cbd5d6000] at 2026-10-25 18:18:22 on branch tip-764_tcl90 — Version 16g has been released. The `set {point}A 1.0 2.0` operation has improved from 1.3 µs to 0.6 µs, and bitwise operators now interpret fields as numeric values. Point 1: `set {T}x a b…` Fast path: This is triggered when the type is a product type consisting entirely of `int`, `double`, or `string` fields, with a number of values matching the number of fields, and no annotated values. Each value is validated in place and then stored directly, without being copied. If a value is rejected, the system falls back to the general path, which provides the standard error message. General path: The constructed content is no longer copied a second time, and the variable is written directly, avoiding a redundant name lookup. New patch `set-type-local-compile.patch`: Within a procedure, `x` is treated as a compiled local variable (applicable only to simple names, excluding those with `::` or parentheses). Benchmarks: `{pi}` (consisting of an `int` and a `string`) has improved from 1.25 µs to 0.63 µs. Other forms—such as those using named fields or nested product types—remain unchanged. Remaining overhead: Performance is currently at 0.6 µs, compared to 0.2 µs for `X is point = (…)`. This gap is primarily due to the call to `::tcl::annotraw`, which creates and subsequently releases an annotated object during every execution, while also re-reading the type definition. The next logical step would be to compile `set {T}x` in a way that eliminates this call. Point 2: Bitwise operators New patch `expr-champs-bits.patch`: When `$a(x)` is used with bitwise operators (`&`, `|`, `^`, `<<`, `>>`, or `~`), it is now compiled into a `loadFieldNum` operation. Attempting to use a `double` field in this context results in the same error as before. Verifications Test t89_set_type_rapide: output is identical to v16b, regardless of whether TCL_TYPES_COMPACT is set to 0 or 1. tests_tclsh suite: all 67 tests pass in both configurations. valgrind: clean, aside from the usual warning from executable_pe.tcl upon exit. make test: 61 failures—the same as in the reference set. maj.sh: tested on a v16f source tree; it correctly applies the two patches added at the end of ORDRE.txt, and a second run identifies them as already applied. Since both patches affect tclCompExpr.c and tclCompCmdsSZ.c, a full recompilation is required. I have updated the documentation (core/README.md, REPRISE.md, and section 15 of ANNOTATIONS.fr.md) and marked the corresponding item as complete in the project schedule. typeparse.zip and REPRISE.md are attached. (user: Florentis, size: 2000) [annotate] [blame] [check-ins using]
# v16g : set {T}x a b... d'un produit de scalaires (voie rapide) et # lecture numérique des champs pour les opérateurs de bits dans expr. type def point {{double}x; {double}y} type def pi {{int}a; {string}b} type def seg {{point}p; {point}q} proc essai {nom script} { if {[catch {uplevel 1 $script} r]} {puts "$nom : erreur : $r"} else {puts "$nom : $r"} } proc p1 {} { set {point}A 1.0 2.0 list $A [type get $A] [info locals] } essai "produit de doubles" {p1} proc p2 {} { set {pi}Q 3 zz list $Q [type get $Q] $Q(a) $Q(b) } essai "int et chaîne" {p2} proc p3 {} { set {point}A 1.0 abc } essai "valeur refusée (voie générale)" {p3} proc p4 {} { set {pi}A 3.5 zz } essai "entier refusé" {p4} proc p5 {} { set {point}A 1.0 } essai "arité" {p5} proc p6 {} { set {point}A {x}1.0 {y}2.0; set A } essai "champs nommés" {p6} proc p7 {} { set p [set {point}P 1 2]; set {seg}S $P $P; list $S [type get $S] } essai "produit de produits" {p7} proc p8 {} { set {pi}A 1 x; set A(a) 5; set A(a) zz } essai "contrat après la voie rapide" {p8} proc p9 {} { upvar 1 G g; set {point}g 4 5; return $g } set G {} essai "variable liée (upvar)" {list [p9] $G [type get $G]} proc p10 {} { set {point}A(x) 7; set A } essai "chemin de constructeur" {p10} proc p11 {} { set {int}A(k) 5 } essai "élément de tableau refusé" {p11} proc p12 {} { set v 1.5; set w 2.5; set {point}A $v $w; list $A [type get $A] } essai "valeurs substituées" {p12} # Opérateurs de bits : le champ est lu comme nombre (loadFieldNum). proc b1 {} { set {pi}q 13 a list [expr {$q(a) & 3}] [expr {$q(a) | 16}] [expr {$q(a) ^ 1}] \ [expr {$q(a) << 2}] [expr {$q(a) >> 1}] [expr {~$q(a)}] } essai "bits sur un champ" {b1} proc b2 {} { set {point}p 1.5 2; expr {$p(x) & 1} } essai "bits sur un double" {b2} proc b3 {} { array set t {k 6}; expr {$t(k) & 3} } essai "tableau ordinaire" {b3} essai "bytecode : lectures numériques" {regexp -all {loadFieldNum} [tcl::unsupported::disassemble proc b1]}