Artifact a6be7ec87310a93085c40d5182571a13c0461af32e75d1eb6d2c6b165bb8eb18:
- File typeparse/tests_tclsh/t110_canonic_parse.out — part of check-in [dd10cbf51b] at 2026-11-29 17:26:47 on branch tip-764_tcl90 — Notes and types together Notes now follow a value at any depth: path writes (set P(y) $n), product fields (construction, $P(x), $P(x,y), $P(*)), and nested paths. Only data notes travel; a pending field label such as {point/x} stays with the constructor. type parse reads notes as data: {mm@src=capteur}1500 no longer fails. Typed collections keep their type on the way out The element type is carried once by the collection and applied when a value leaves it. Elements are not copied, and compact storage is kept. lindex, lsearch -inline, dict get and dict for give a typed element. lrange, lreverse, lsort (including -unique and -command), lsearch -all -inline and dict filter keep the collection type; dict values gives list.T. The comparison command of lsort -command receives typed values, so a {kg} parameter rejects an mm. Canonical text with modes type canonic and type parse share the options -type, -notes, -value, -deep and -list. With no option, they cover everything, at full depth. Element notes and element types under any are written as prefixes, for example {list.mm}{{{@ok}5} 7}. The round trip is exact, checked on randomly generated values. -list returns {type notes value}, ready for lassign or a tuple assignment. type parse -list splits a canonical text by syntax alone, so the type may be unknown to the reader. Reading a canonical text never executes anything. Proposed public C API: Tcl_GetCanonicObj, Tcl_ParseCanonicObj and the TCL_CANON_* flags. Behaviour change: type canonic -notes now returns the notes alone; the old meaning is -type -notes. Core conversions no longer drop annotations A typed value used as a number, a regexp, a script, a command name, an option, a subcommand, a channel, an encoding, a namespace or a clock format keeps its type and notes. Core patch: annot-conversions.patch. New loss detector: ::tcl::unsupported::annotlost or TCL_TYPE_TRACE=lost. Found along the way, a Tcl 9 bug: lsort checked getElementsProc on objv\[1\] instead of the list. Fixes In expr, x is T now agrees with type is: an mm is not a kg, even though both are built on int. An integer typed as double now prints as 7.0. Known limits A typed value used as a variable name loses its annotation. So does a value whose representation is taken over by an extension type. type parse -value on an unknown type leaves the element prefixes in place. Tests 128 script tests pass in 5 modes; valgrind finds no leaks or errors. The fuzzers give identical output across modes. In the full core suite, fileName, http11, socket and tcltest show failures that do not appear when these files run alone. The comparison run with the old version used different settings, so this is not confirmed as environment-only. Next type eval: implicit conversion inside its block, and unit algebra for * and /. (user: Florentis, size: 2463) [annotate] [blame] [check-ins using]
== scalaires int 0x10 {{int}16} ≡ double 2e1 {{double}20.0} ≡ grand entier {{int}123456789012345678901234567890} ≡ string avec espaces {{string}{a b}} ≡ string vide {{string}{}} ≡ nominal {{Jour110}lundi} ≡ alias : le type visé {double}3.0 == conteneurs : le texte reconstruit list.int espacée {list.int}{1 2} list de listes {{list.list.int}{{1 2} 3}} ≡ dict.int {{dict.int}{a 1 b 2}} ≡ produit nommé {{pt110}{1 2.5}} ≡ produit anonyme {{{{int}a; {double}b}}{1 2.0}} ≡ type d'un espace {{::g110::P}{1.0 2.0}} ≡ list d'un type d'espace {{list.::g110::P}{{1.0 2.0}}} ≡ cases (-compact) {list.double}{1.0 2.0} == sommes et unions somme : la variante {{S110/d}2.0} ≡ littéral {{opt110}none} ≡ union : lue du contenu {{num110}31} ≡ list.num110 {{list.num110}{1 2.0 16}} ≡ == notes une note {{double@vitesse}5.0} ≡ un ensemble trié {double@alpha,zeta}5.0 seulement notée {{@vitesse}5} ≡ -type -notes double@vitesse -type -notes sans note pt110 -notes (v18k) vitesse -notes sans note (v18k) note encodée {{@%22a%2Cb%22}x} {"a,b"} élément noté normalisé {list.double}{{{@vitesse}5.0} 6.0} == refus valeur nue {bare}5 pas d'accolade ERREUR type parse: "5" is not {TYPE}content, {TYPE@notes}content or {@notes}content sans contenu ERREUR type parse: "{int}" is not {TYPE}content, {TYPE@notes}content or {@notes}content deux mots ERREUR type parse: "{int}x y" is not {TYPE}content, {TYPE@notes}content or {@notes}content type inconnu ERREUR unknown type "intt" contenu refusé ERREUR expected integer but got "abc" note vide ERREUR type parse: "{int@a,,b}5" is not {TYPE}content, {TYPE@notes}content or {@notes}content encodage incomplet ERREUR type parse: "{int@%4}5" is not {TYPE}content, {TYPE@notes}content or {@notes}content arguments ERREUR wrong # args: should be "type canonic ?-type? ?-notes? ?-value? ?-deep? ?-list? value"