Artifact 88ba2ee9b7d94f93469e45de8fcb8654970971748aa72f937e9854c0f71cf3fe:
- File typeparse/tests_tclsh/t70_compact.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: 2617) [annotate] [blame] [check-ins using]
disposition point : size 16 align 8 fields {{x float 8 0} {y float 8 8}} disposition pt3 : size 32 align 8 fields {{id int 4 0} {p.x float 8 8} {p.y float 8 16} {w float 4 24}} string : prod<s:string;> has no compact layout: only fixed-size scalars (int(s,n), int(u,n) with n = 8, 16, 32 or 64, double, double(32|64)), products of them and fixed-size lists list(n) of them (at most 4096 parts per element) int : int has no compact layout: only fixed-size scalars (int(s,n), int(u,n) with n = 8, 16, 32 or 64, double, double(32|64)), products of them and fixed-size lists list(n) of them (at most 4096 parts per element) construire identique compacte 0 {0.5 1.5} {2.5 3.5} {-1.0 4.0} type, llength identique compacte 0 list<point> 2 lindex, type identique compacte 0 {2.5 3.5} point 3.5 chemin P(1.y) identique compacte 0 3.5 double 2.5 foreach identique compacte 0 0.5 point 2.5 point écrire P(1.y) identique compacte 0 {0.5 1.5} {2.5 9.5} écrire 9 (non canonique) identique ordinaire 0 {0.5 1.5} {2.5 9} lappend identique compacte 0 {0.5 1.5} {7.5 8.5} lappend invalide identique compacte 1 expected floating-point number but got "a" lset identique compacte 0 {1.25 2.25} {2.5 3.5} lrange, lsort identique compacte 0 {{0.5 1.5}} {{0.5 1.5} {2.5 3.5}} non canonique 1 2 identique ordinaire 0 {1 2} {3 4} espaces gardés identique compacte 0 {0.5 1.5} {2.5 3.5} produit imbriqué identique compacte 0 {{7 {0.5 0.25} 0.5} {-3 {1.0 2.0} 0.25}} 2.0 point int(s,32) trop grand identique compacte 1 value "99999999999" does not fit in int(s,32) double(32) inexact identique ordinaire 0 {7 {0.5 0.25} 0.1} u8 identique compacte 0 {1 2 3 255} 1 {value "256" does not fit in int(u,8)} {1 2 3 255} vecteur de double identique compacte 0 {0.1 0.2 0.30000000000000004} 0.4 lire après lindex identique compacte 0 0.5 1.5 vue gardée après écriture identique compacte 0 {0.5 1.5} {{7.5 1.5} {2.5 3.5}} copie puis écriture identique compacte 0 {{0.5 1.5}} {{0.5 5.5}} élément vers autre liste identique compacte 0 {2.5 3.5} {0.5 1.5} string length identique compacte 0 9 list<point> contenu identique compacte 0 {0.5 1.5} binary decode identique compacte 0 {1.5 2.5} {3.5 4.5}