Artifact 1e421dfd6b7fa06b4a42ada5aca24e2551510986792d42699590d0b1adc6cf24:
- File typeparse/tests_tclsh/t88_parties_produit.tcl — part of check-in [43c57f18b6] at 2026-11-04 08:32:02 on branch tip-764_tcl90 — What v16n introduces: `type is {disjoint?}S` returns the pairs of variants that can accept the same value; it returns nothing if the sum is disjoint. `type is {strict?}S` is also available. `type def {-strict}S`: the variant is never inferred (guessed). A "bare" value is rejected: "value 5 names no variant of the strict sum S: write `{i:}value` or `{S.i}value`." Accepted forms include: an already-typed value, a label such as `{i:}` or `{S.i}`, or a type cast like `S.i`. A variant literal is identified by its value, and when stored in a typed variable, the current variant is preserved. `type def {-deduce}S` retains the previous behavior: the strictest variant takes precedence. Warning: An overlapping sum defined without any options will trigger a message on `stderr` suggesting either `{-deduce}` or `{-strict}`. A disjoint sum will not trigger such a message. Multiple options: `{-compact, -strict}` can be used within the annotation syntax. The structure is flattened (e.g., `{-a.(b=1, c=2)}` becomes `-a.b=1` and `-a.c=2`), meaning sub-option syntax is supported. Currently, no `type def` options utilize this; for instance, `{-strict.x=1}` will result in a clear error message. (user: Florentis, size: 1190) [annotate] [blame] [check-ins using]
# t88 : $P(*) d'un produit typé (toutes ses parties) par le raccourci de # lecture : mêmes valeurs et mêmes types que le chemin général (types # différents : list.any des champs typés ; tous identiques : list.T), # produit imbriqué, forme compacte, lassign ; les autres formes ($P(*.x), # sommes, any) restent au chemin général. type def Sample {{int}id; {double}value; {int}flags} type def point {{double}x; {double}y} type def seg {{point}a; {point}b} type def {-compact}nuage list.point type def {-deduce}forme {{double}cote, {string}nom} type def boite {{forme}f; {int}n} proc montre {v} {list $v [type get $v] [lmap e $v {type get $e}]} proc p1 {s} {montre $s(*)} set {Sample}s 1 2.5 0 puts "mixte : [p1 $s]" set {point}p 1.0 2.0 puts "identiques : [p1 $p]" set {seg}g(a,b) {1.0 2.0} {3.0 4.0} puts "imbriqué : [p1 $g] [montre $g(*.x)]" set {nuage}N {0.5 1.5} {2.5 3.5} proc p2 {N} {set q [lindex $N 1]; montre $q(*)} puts "case : [p2 $N]" proc p3 {s} {lassign $s(*) a b c; list $a $b $c [type get $b]} puts "lassign : [p3 $s]" set {boite}bx(f,n) {cote:}2.0 3 puts "somme : [p1 $bx]" proc p4 {s} {set s(value) 9.5; montre $s(*)} puts "après écriture : [p4 $s] $s"