Artifact 41f50ab2b4587922a32436f979d304a073c64a860bd6a9276c0438097a52a446:
- File typeparse/tests_tclsh/t90_listes_fixes_en_cases.out — part of check-in [1972295ee9] at 2026-10-26 04:24:01 on branch tip-764_tcl90 — Version 16h is ready: your declaration will now be accepted, and it works for any number of dimensions you require. ```tcl type def {-compact}matrix2 list(3).list(3).double set {matrix2}M {1 2 3} {4 5 6} {7 8 9} ;# normalized to {1.0 2.0 3.0} ... type is {compact?}$M ;# 1 expr {$M(0.0) * $M(1.1) + $M(2.2)} ;# 14.0, read from the storage cell set M(1.2) 60.5 ;# written to the storage cell lindex $M 1 2 ;# 60.5: a row remains a list ``` **How it is stored** An element of type `list(n).T` is stored like a C array `T[n]`, provided that `T` itself can be laid out in storage cells—whether it is a scalar, a product, or another fixed-size list. Example: `list(2).list(3).list(2).int(s,32)` results in the equivalent of `int32_t[2][3][2]`. A product containing a field `{list(2).double}v` is now stored entirely within its cells. A single cell can contain a maximum of 4,096 parts. A 100×100 matrix is accepted (100 cells of 800 bytes each), while `list(2).list(5000).double` is rejected, with an error message explaining why. `tcl::unsupported::compact layout` displays the parts using `i.j` notation. For a parameterized family, you must use a named instance: `type def {-compact}mat3 mat(3,3)` works as expected. ** Performance** |Operation |Before | v16h| |!---|---:|---:| |Reading $M(i,j)| 0.9 µs| 0.23 µs| |Setting M(i,j) to a number| 2.2 µs| 0.14 µs| |Product of two 3×3 matrices (cell-based)| 89 µs| 33 µs| |The same product (standard form)| 113 µs| 75 µs| Reading occurs directly from the cell, including for operands compiled as `loadFieldNum` within an expression. Writing occurs in-place only if no other reference to the value exists—meaning no copies and no active views. Otherwise, the system reverts to the previous approach. Traces and the established contract are fully respected. The same 3×3 matrix product, when performed using raw lists (`lindex`/`lset`), takes 9 µs; this remains approximately 3.5 times slower than "bare" Tcl. **Two bugs fixed** `lset L i j v` on a list stored in cells was reading from deallocated memory. This bug already existed in v16g with products—for example, `lset P 0 1 5.0` on a compact `list.point`—and was identified using Valgrind. `lindex $M i j` was losing the element read from the cell, resulting in a memory leak—also detected by Valgrind. **Verifications** New test `t90_listes_fixes_en_cases`: each operation is performed on both a matrix stored in cells and its standard counterpart. This includes 3D cases, specific data types (e.g., `binary`), compact cells, and in-place writes (where a view, a copy, or an element already traversed retains the old value, while a "trace" reflects the new one). `t70_compact` and `t72_compact_type`: expected output updated; only the text of the rejection message has changed. All 68 tests pass in both modes, and every file produces identical output regardless of whether the compact format is used. Valgrind reports no issues, aside from the standard, recurring warning from `executable_pe.tcl` upon exit. `make test` continues to yield the same 61 failures. (user: Florentis, size: 3144) [annotate] [blame] [check-ins using]
disposition : size 12 align 2 fields {{0.0 int 2 0} {0.1 int 2 2} {0.2 int 2 4} {1.0 int 2 6} {1.1 int 2 8} {1.2 int 2 10}} disposition produit : {a float 8 0} {v.0 float 8 8} {v.1 float 8 16} en cases : 1 valeur : {{1.0 2.0 3.0} {4.0 5.0 6.0} {7.0 8.0 9.0}} m3 ligne : {4.0 5.0 6.0} list(3)<double> case : 6.0 double chemin : 7.0 double chemin ligne : {4.0 5.0 6.0} list(3)<double> chemin end : 9.0 chemin hors bornes : erreur : list index "3" out of range expr : 14.0 lindex end : 8.0 llength : 3 3 foreach : 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 lmap : 6.0 15.0 24.0 écriture chemin : {{1.0 2.0 3.0} {4.0 5.0 60.5} {7.0 8.0 9.0}} m3 6.0 lset : {{11.0 2.0 3.0} {4.0 5.0 6.0} {1.0 1.0 1.0}} {} lset mauvaise ligne : {1.0 2.0 3.0} {4.0 5.0 6.0} {1 1} lset mauvais nombre : {1.0 x 3.0} {4.0 5.0 6.0} {7.0 8.0 9.0} ligne entière : {7.0 7.0 7.0} {4.0 5.0 6.0} {7.0 8.0 9.0} mauvaise arité : erreur : list(3)<double> needs exactly 3 elements but got 2 mauvais nombre : erreur : expected floating-point number but got "x" tuple : {1.0 2.0 3.0} {4.0 5.0 6.0} {7.0 8.0 9.0} partage : 1.0 99.0 chaîne : 41 3D en cases : 1 3D chemin : 11 3D lindex : 12 3D plan : {{1 2} {3 4} {5 6}} list(3)<list(2)<int(s,32)>> 3D écriture : {{1 2} {3 40} {5 6}} {{-1 -2} {9 10} {11 12}} 3D débordement : erreur : value "3000000000" does not fit in int(s,32) liste extensible en cases : 1 lappend : {{1 2 3 4} {5 6 7 8} {9 10 11 12}} 3 lappend mauvais : {1 2 3 4} {5 6 7 8} {9 10 11 300} u8 : 8 produit à liste en cases : 1 produit chemin : 6.0 1.5 list(2)<double> produit écriture : {1.5 {20.0 3.0}} {4.5 {5.0 6.0}} cast : {{1.0 2.0 3.0} {4.0 5.0 6.0} {7.0 8.0 9.0}} m3c 1 binaire : 0100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c000000 binaire retour : {{{1 2} {3 4} {5 6}} {{7 8} {9 10} {11 12}}} 1 cells : {{1 2} {3 4}} list<list(2)<int(s,16)>> binaire double(64) : {{1.0 2.5} {-3.0 4.25}} 1 32 trace (procédure) : 15.0 erreur de type de ligne : erreur : list(3)<double> needs exactly 3 elements but got 2 contrat sur une case : erreur : expected floating-point number but got "abc" grande matrice : 800 trop grande : erreur : type def {-compact}m5000: only a list of fixed-size scalars (int(s,n), int(u,n) with n = 8, 16, 32 or 64, double, double(32|64)), of products of them or of fixed-size lists list(n) of them (at most 4096 parts per element), or such a product, can be compact, not m5000 vue gardée : {1.0 2.0 3.0} {5.0 2.0 3.0} 1 copie gardée : 9.0 -1.5 éléments parcourus gardés : {{1.0 2.0 3.0} {4.0 5.0 6.0} {7.0 8.0 9.0}} {{1.0 2.0 3.0} {4.0 0.5 6.0} {7.0 8.0 9.0}} chaîne refaite : {{1.0 2.0 3.0} {4.0 5.0 6.0} {7.0 8.0 9.0}} {{1.0 2.5 3.0} {4.0 5.0 6.0} {7.0 8.0 9.0}} 41 trace d'écriture : 33.0 indices calculés : {{10.0 2.0 3.0} {4.0 50.0 6.0} {7.0 8.0 90.0}} 1 {bad index "1.2": must be integer?[+-]integer? or end?[+-]integer?} {0.0 8.0 90.0} refus et normalisation : 1 {expected floating-point number but got "abc"} 1 {list(3)<double> cannot grow beyond 3 elements} {7.0 2.0 3.0} 3D sur place : 1 {value "3000000000" does not fit in int(s,32)} {{{1 2} {3 4} {5 6}} {{7 8} {9 10} {11 -7}}}