Artifact a5f8be491ccc00e7d5c46d2aa995d7be9e7fc4b8e97ed186381808ac28a261a6:
- File typeparse/tests_tclsh/t70_compact.out — part of check-in [7952bb1028] at 2026-10-24 04:37:06 on branch tip-764_tcl90 — V15q `type def {-compact}T`, `type is {compact?}`, and `type {c!}export` are now in place, following the chosen design—this is version v15q, available in `typeparse.zip`. `type is {compact?}polygone` checks the type, while `type is {compact?}$P` checks the value. I did not need to modify local annotations for value-based checks; the value retains only its content, which is precisely what holds the underlying data cells. tcl type def {-compact}polygone list.point set {polygone}P {0 0} {4 0} {4 3} ;# {0.0 0.0} {4.0 0.0} {4.0 3.0} type is {compact?}polygone ;# 1: the type requires it type is {compact?}$P ;# 1: the value is stored in cells string length $P; type is {compact?}$P ;# still 1 type {c!}export point ;# the C header (replaces `type c`) Normalization upon construction: `0` becomes `0.0`, and `0x10` becomes `16`. A `double(32)` is rounded to a `float`: `0.1` becomes `0.10000000149011612`. This normalization also applies to `set P(i.x)`, `lset`, and `lappend`. Conversions on a copy: core string and byte functions now operate on a string copy, maintained alongside the data cells. This is implemented via the new kernel patch `compact-conversions.patch`, which modifies `tclStringObj.c` and `tclBinary.c`. `tcl::unsupported::content` returns a copy that shares the same underlying data cells. This also applies to the global switch: in v15p, `string length $P` would break the compact form, but that is no longer the case. The following are disallowed in a definition: a type that is not a list of fixed-size elements (the definition is discarded, and the name remains available); an unknown option; `{-compact}` applied to an alias; a parameterized family (which I have not yet implemented). Export: `{llvm!}export` returns "not available yet," and an export without a target—or with an unknown target—is rejected. I discovered a flaw along the way: `string reverse` could modify the content of an annotated value in-place. This is no longer the case. A limitation regarding the `is` type check: if the text of a value also happens to be a type name (a value that is literally a type name), the query is interpreted as a type check. I have noted this in the planning. Tests against v15p: All expected outputs pass, with the exception of `t70_compact.out`; I have regenerated it because `string length` now maintains the compact format there. All tests and examples yield the same output, regardless of whether `TCL_TYPES_COMPACT=1` is set. The Tcl `string*`, `binary`, `stringObj`, `utf`, `dict`, `lset*`, and `list*` test suites show 3,482 passes out of 3,579, with 97 skipped and zero failures—consistent with v15. `valgrind` (PURIFY build) reports no issues for `t70_compact`, `t71_type_c`, and the new `t72_compact_type`. (user: Florentis, size: 2483) [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)) and products of them 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)) and products of them 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}