Skip to content
Tcl Source Code Check-in [582865c204]
Login

Check-in [582865c204]

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: 582865c20422129bc99403d28204db5d397e09806f222c51b3de6bdaa4c3525d
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