Artifact d6dd5549487c88664fe1f70934b9471d0c8c27641528eb4cc9f6745a0122d9ed:
- File typeparse/tests_tclsh/t72_compact_type.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: 2616) [annotate] [blame] [check-ins using]
type is {compact?}polygone 0 1 type is {compact?}list.point 0 0 type is {compact?}point 0 0 construit, normalisé 0 {0.0 0.0} {4.0 0.0} {4.0 3.0} type is {compact?}$P 0 1 string length 0 29 1 string reverse 0 \}0.3\ 0.4\{\ \}0.0\ 0.4\{\ \}0.0\ 0.0\{ \}0.3\ 0.4\{\ \}0.0\ 0.4\{\ \}0.0\ 0.0\{ 1 string range 0 {{0.0 0.0}} 1 dict size (refus) 0 1 1 set P(1.x) 7 0 {{0.0 0.0} {7.0 0.0} {4.0 3.0}} 1 lappend {1 2} 0 {{0.0 0.0} {7.0 0.0} {4.0 3.0} {1.0 2.0}} 1 lset 0 {5 5} 0 {{5.0 5.0} {7.0 0.0} {4.0 3.0} {1.0 2.0}} 1 lappend invalide 1 expected floating-point number but got "a" contenu puis conversion 0 1 list.point ordinaire 0 {{0 0}} 0 cast vers polygone 0 {{1.0 1.0} {2.0 2.0}} 1 valeur ordinaire 0 0 double(32) arrondi 0 0.10000000149011612 0.5 int(u,8) 0 {1 2 16} 1 {value "256" does not fit in int(u,8)} refus : list.string 1 type def {-compact}noms: 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 noms le nom refusé reste libre 0 noms un produit (v15t) 0 1 liste de ce produit 0 {{1.0 2} {3.0 4}} 1 champ liste d'un produit 0 {1 {{16.0 5}}} 1 0 refus : produit avec chaîne 1 type def {-compact}pq: 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 pq refus : option inconnue 1 type def: unknown option {-zz}: must be {-compact} refus : alias 1 type alias: unknown option {-compact} (an alias is not a new type: it takes no option) refus : famille 1 type def {-compact}: not yet for a type family (v({int}n)) question inconnue 1 unknown question "zz?": must be compact? sans question 1 type is takes one question: type is {compact?}T or type is {compact?}$value export : llvm 1 type export: the target llvm! is not available yet: must be c! export : sans cible 1 type export needs one target: type {c!}export T ?T ...?