Skip to content
Tcl Source Code Check-in [1972295ee9]
Login

Check-in [1972295ee9]

Overview
Comment: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.
Timelines: family | ancestors | descendants | both | tip-764_tcl90
Files: files | file ages | folders
SHA3-256: 1972295ee97441d2f9491160830d86c60a3a3b0a23f0077a4675a7f64c8f1d07
User & Date: Florentis on 2026-10-26 04:24:01.824
Other Links: branch diff | manifest | tags
Context
2026-10-26
06:42
The `examples/matrices/` example is ready, and all 22 checks in its `test.tcl` script pass. During p... check-in: 7f8d29abf6 user: Florentis tags: tip-764_tcl90
04:24
Version 16h is ready: your declaration will now be accepted, and it works for any number of dimensio... check-in: 1972295ee9 user: Florentis tags: tip-764_tcl90
2026-10-25
18:18
Version 16g has been released. The `set {point}A ​​1.0 2.0` operation has improved from 1.3 µs ... check-in: 2cbd5d6000 user: Florentis tags: tip-764_tcl90
Changes