Artifact b0eb4be9b08089e1424a2d7ca32f9d4dc04d15585c1952d17f0354ed66e5a38f:
- File typeparse/tests_tclsh/t63_separateurs.tcl — part of check-in [289eebd31b] at 2026-11-06 11:24:44 on branch tip-764_tcl90 — Complete revision of "sums" (sum types). A distinction is now made between two clearly separate categories: "unions," where the specific variant can be reliably inferred from the structure of the data string, and "sums," where the structure of the data string is insufficient to definitively determine the variant. A new syntax for unions has been introduced, now utilizing the `|` symbol. E.g.: `type def matrix {{list(3).list(3)}matrice3x3 | {list(2).list(2)}matrix2x2}` Any ambiguous union will be rejected during construction, triggering an error message. "Sums" now function like "tagged unions" in C—that is, they consist of a union paired with a tag. Consequently, one must reference the tag to identify the specific variant. Sums are always written using commas (`,`). E.g.: `type def Temperature {{double}celsius, {double}farenheit}` (user: Florentis, size: 507) [annotate] [blame] [check-ins using]
# t63 : ";" et "," mêlés au même niveau refusés ; un groupe champ de produit a un nom ; # les variantes anonymes d'une somme restent permises. foreach d { {{int}a; {int}b, {string}c} {{int}a, {int}b; {string}c} {{int}a; {{int}b, {string}c}} {{int}a; {{int}b, {string}c}u} {{{int}a; {int}b}p, {string}c} {{{int}a; {int}b}, {string}c} {{int}, {string}} {{int}x; {int}y} } { incr k; puts "[format %-34s $d] -> [catch {if {$k in {5 6 7}} {type def M$k $d} else {type def M$k $d}} m] $m" }