Artifact 7c0faa558643dbb3e9d3c29f2e86f7fd425b75071ab89fbbde6101ddb030f4da:
- File typeparse/tests_tclsh/t62_liens_ecriture.tcl — part of check-in [d01807137c] at 2026-10-23 09:56:45 on branch tip-764_tcl90 — This issue had already been fixed in the code; all that remained was to write the documentation, which is now done. I also identified a limitation, which I have noted in the project plan. Existing functionality Since v14, `lset L 1 C` and `lappend L C` correctly store the canonical name `::C`. In v13, they still stored `C`. As for `lappend L 5`, it stores `::5`—exactly like the construct `(set {list.var.int}L 5)`—because `5` is a valid Tcl variable name. Both approaches therefore behave in the same way. An empty name is rejected in both cases. Documentation (French version, § 5.3, following the example of the variable link) This paragraph follows the rule established on October 19, which aligns with standard Tcl principles: tcl set r [lindex $L 0] ;# ::A (type var<int>) set $r ;# 7 set {var.int}R A ;# ::A ; set $R returns 7 set L(0) 8 ;# writes 8 into ::A A standalone link—when removed from its container—resolves to the variable's canonical name, and `set` returns its value. When accessed via a path within a container, reading follows the link. Writing via a path updates the target variable, subject to the enforcement of its defined contract. Any write operation involving a link results in the storage of the canonical name. Identified limitation A link to a local procedure variable has a canonical name specific to its execution frame (e.g., `frame:1:x`). While `$M(0)` correctly follows this link, `set [lindex $M 0]` fails (with the error "can't read 'frame:1:x'"), because this is not a name recognized by Tcl. I have described the limitation in the documentation and added an "item to be decided" to the roadmap, with three options: allow the variable lookup mechanism to recognize this name, as long as the scope exists; make a name usable within the current scope; stick to what is stated in the documentation. I have also added the test `t62_liens_ecriture` and a note in `noyau/LISEZMOI.md`. There are no code changes, so nothing needs to be recompiled; `typeparse.zip` is up to date. (user: Florentis, size: 1190) [annotate] [blame] [check-ins using]
# t62 : liens var : nom canonique à chaque écriture ; lecture d'un lien seul. set {int}A 1; set {int}B 2; set {int}C 3 proc t {l s} { set rc [catch {uplevel 1 $s} m]; puts [format "%-40s %s %s" $l $rc $m] } t "construction" {set {list.var.int}L A B; set L} t "lset L 1 C" {lset L 1 C; set L} t "lappend L C" {lappend L C; set L} t "lappend L 5" {lappend L 5} t "lappend L {}" {lappend L {}} t "set L(0) C" {set L(0) C; set L} t "lset L 0 {a b}" {lset L 0 {a b}} t "lecture \$L(1)" {set L(1)} proc p {} { set {list.var.int}M A; lset M 0 B; lappend M C; return $M } t "dans une procédure (locaux absents)" {p} namespace eval ns { variable D 4 } t "lappend L ns::D" {lappend L ns::D; set L} set A 1 ; set B 2 set {list.var.int}L A B set A 7 puts "L(0)=$L(0)" set r [lindex $L 0]; puts "r=$r type=[type get $r] set r=[set $r]" set {var.int}R A; puts "R=$R set \$R=[set $R] type=[type get $R]" lset L 1 C; set C 3; puts "lset: $L L(1)=$L(1)" set L(0) 8; puts "écriture par le lien: A=$A" proc p {} { set x 1; set {list.var.int}M x; set x 5; list $M $M(0) [catch {set [lindex $M 0]} e] $e } puts [p]