Overview
| Artifact ID: | 8dbc9b0840544ca162479febfd513c4d35c62b7a0d64fff0b3462c7a25c342ab |
|---|---|
| Ticket: | 0d61d3a2bb905178694d6cde8147039974600274
Tcl interprets two adjacent surrogate code points as a character encoded using UTF-16 |
| User & Date: | dgp on 2021-03-09 17:00:05 |
Changes
- icomment:
This is a dispute over the alphabet of Tcl's value set. Jan is correct to point to TIP 573 as the key issue. All Tcl values have always been (conceptually) "strings", but the precise definition of what is a "string" has varied with time/release. The last large revolution in Tcl's string value definition was the 8.0 -> 8.1 transition. In 8.0 a "string" was a sequence of zero or more bytes. In 8.1, a "string" became a sequence of zero or more UCS-2 values, which our documentation and other writings call "characters". The migration plan for Tcl 9 that Jan has developed appears to aim for a Tcl 9 definition of "string" as "a proper Unicode string". This implies the exclusion of values that are not valid Unicode. The Unicode alphabet does not include the surrogate codepoints. They cannot be included in any valid Unicode string, so on this plan they must no longer be in the Tcl value alphabet. Consequently all the existing tools that could create or manipulate these values in earlier releases have to incompatibly change, and there's a disruption for developers that has to be managed. One factor in favor of a goal to have the Tcl 9 value set be proper Unicode strings is that it moves Tcl more in the direction of using standard components and tools and names and away from its frequent (bad?) habit of inventing its own weird alternatives. That has the potential to make Tcl's code base marginally more attractive to experienced coders. I think there are two categories of reasonable criticism. First, for the first time the Tcl value set is getting reduced. There are values that were once valid in Tcl that no longer will be. This reduces the set of programs that can be written, or easily written. Manipulation of arbitrary UCS-2 sequences in a Tcl script becomes something unnatural in a language that refuses to directly represent those values. This means writing a Tcl script that does UTF-16 encoding/decoding is something that has no implementation that rests easily on the capabilities of the language. It can still be accomplished with suitable use of [binary format|scan t*] (and the inefficiencies inherent in that), but that's not the most satisfying answer to many programmers. It's a task where the language has to be worked around rather than used. From this perspective, the goal itself is flawed, and we should change course and aim to have the Tcl 9 definition of Tcl strings somehow continue to be a superset of the set of all UCS-2 sequences, and we should retain all the tools we have to operate on such values. The second category of reasonable criticism is that the Tcl 9 goal to define proper Unicode strings as Tcl's value set is acceptable, but that the current migration path to get there is bumpier than it ought to be. In that realm, the more specific the complaint, and the offering of alternatives is the best way forward. Also, in this realm, the most useful venue for hashing out the issues would be the production of migration guides for Tcl programmers. Forcing ourselves into the teaching role should force us to uncover just where the rough edges are, and whether they can be sanded down, or whether any are deal-breakers. I tend to agree with the first criticism. From pooryorick's submission I think he does too. Jan has done the work, though. He's held the TIP votes and got the requisite approvals. Tcl 8.7 behaves the way it does (mostly, modulo some errors along the way) because the TCT accepted the changes. Perhaps some of the TCT supporters of this path have not been fully aware of these issues of disruption and representation, and it might be worthwhile to raise discussions on TCLCORE, but I think that's the better venue for confronting the dispute at this point than a ticket asserting a bug. For myself, I've taken the attitude for some time now that no matter my reservations and distaste, if I cannot deliver a better alternative, there's little value in being no more than a naysayer. Pooryorick, if you want to pursue another approach, I'm willing to help where and as I can. I hope that's fair to everyone.
- login: "dgp"
- mimetype: "text/plain"