Overview
| Comment: | Conversion rules between variants are now in place: this is version v15n, found in typeparse.zip. tcl type def temp {{double}celsius, {double}fahrenheit} type convert temp.celsius temp.fahrenheit {{x} {expr {$x*9/5.0 + 32}}} set {temp}t {celsius}100 set t(fahrenheit) ;# 212.0 set u {temp.fahrenheit}$t ;# 212.0, of type temp.fahrenheit type cast temp.fahrenheit $t ;# same Reading an inactive variant, or casting to {S.b}: If a rule exists, it is applied—even between variants with different underlying forms. For variants with the same form but no defined rule, an error occurs: "the current variant of temp is 'celsius', not 'fahrenheit'; both have the same form, so reading one as the other needs a rule: type convert temp.celsius temp.fahrenheit {{x} ...}." Otherwise, it defaults to a standard cast, as in v15k: reading {i}5 via $v(s) yields 5. This resolves the question left open in v15k regarding the reading of an inactive variant. Limitations, as previously agreed: Rules do not apply during type inference (e.g., `set {temp}y 5` remains ambiguous), nor during assignment (e.g., `set t {fahrenheit}50` changes the variant without performing a conversion). Rules cannot be chained, and each direction must be explicitly declared. `type convert` will reject cases involving two different sum types, an unknown variant, the same variant specified twice, or a mix of a variant and a simple (non-sum) type. For a sum type with a selector S($field), converted reads work, but the selector field itself cannot be modified via this mechanism. Two fixes included: Previously, `{temp.fahrenheit}$t` would ignore the requested variant and leave the value as `temp.celsius`. `type cast S.v` … previously resulted in an "unknown type 'v'" error. Both now work. Tests against v15: No new discrepancies; all expected `.out` outputs pass. Valgrind reports no issues with the new test cases. New test: `t67_conversion_variantes`. I have documented everything in `doc/ANNOTATIONS.fr.md` (section 8 and the path table) and in `noyau/LISEZMOI.md` (v15n). In the project plan, I have marked this item as complete, alongside the note regarding the current variant used for disambiguation. Update: Replace `tclTypes.c`, `tclTypes.h`, `tclTypePath.c`, and `tclAnnotObj.c` in the `generic/` directory, then run `make`. There is no kernel patch; `maj.sh` handles the update. |
|---|---|
| Timelines: | family | ancestors | descendants | both | tip-764_tcl90 |
| Files: | files | file ages | folders |
| SHA3-256: |
582865c20422129bc99403d28204db5d |
| User & Date: | Florentis on 2026-10-23 11:20:46.831 |
| Other Links: | branch diff | manifest | tags |
Context
|
2026-10-23
| ||
| 11:38 | Addressing "lset leak via TclLsetList (Claude)" Shared a file, used Claude Docs, executed 29 command... check-in: d03339047e user: Florentis tags: tip-764_tcl90 | |
| 11:20 | Conversion rules between variants are now in place: this is version v15n, found in typeparse.zip. t... check-in: 582865c204 user: Florentis tags: tip-764_tcl90 | |
| 11:07 | Let’s address the point: "Variants with the same form—if multiple equally strict variants are ap... check-in: b00991eb89 user: Florentis tags: tip-764_tcl90 | |
Changes
Modified generic/tclAnnotObj.c
from [72fb27ea9b]
to [c508d04558].
[diff]
Modified generic/tclTypePath.c
from [91a81dcc6a]
to [ebb6e8d853].
[diff]
Modified generic/tclTypes.c
from [96594d1658]
to [6227105702].
[diff]
Modified generic/tclTypes.h
from [7045111ace]
to [4068312d59].
[diff]
Modified typeparse/doc/ANNOTATIONS.fr.md
from [e694d22994]
to [26ebc4d05e].
[diff]
Modified typeparse/noyau/LISEZMOI.md
from [c4af277859]
to [3f3d688888].
[diff]
Modified typeparse/tclAnnotObj.c
from [22094209f0]
to [c508d04558].
[diff]
Modified typeparse/tclTypePath.c
from [6b228cbf41]
to [ebb6e8d853].
[diff]
Modified typeparse/tclTypes.c
from [343cc86e41]
to [6227105702].
[diff]
Modified typeparse/tclTypes.h
from [c1f08167ed]
to [4068312d59].
[diff]
Added typeparse/tests_tclsh/t67_conversion_variantes.out version [37a21f921e].
Added typeparse/tests_tclsh/t67_conversion_variantes.tcl version [d6d585f9fd].