Artifact fb77fd48feef7350b2c30054a0380d378a625c9d1174d0b47c221fb658348a03:
- File typeparse/tests_tclsh/t29_deref_arbres_sommes.tcl.out — 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: 744) [annotate] [blame] [check-ins using]
somme : b ::A -> b 1 (deref(mix).b) b=1 variante a : a 5 (deref(mix).a) variante s : s hello (deref(mix).s) liste de sommes : {b 1} {a 7} {b 2} deref(mix).b deref(mix).a deref(mix).b bt : node {{leaf ::A} {leaf ::B}} -> node {{leaf 1} {leaf 2}} (deref(bt).node) premiere feuille : deref(bt).leaf = 1 arbre : 1 {{2 {}} {3 {}}} (deref(tree(var))) racine=1 enfants=2,3 apres A=100 : instantane=1 lien=100 nouvel instantane=100 ; meme type : 1 1 type deref: at children.1.value: can't read "::C": no such variable graphe : A {{B ::nc} {C ::na}} (deref(node)) voisins de A : B C ; voisins de B vus depuis A : ::nc un niveau de plus : B {{C ::na}} ; voisin de B : C 1 type deref: at next.0: can't read "::nb": no such variable