summaryrefslogtreecommitdiff
path: root/NEWS.md
diff options
context:
space:
mode:
authorGravatar Sam Atman2025-04-30 20:30:39 -0400
committerGravatar Sam Atman2025-04-30 20:30:39 -0400
commit10048b0d31d0db923ae39c6bbd67139ed6252f6f (patch)
tree65df1666aacd102f59b4ac0844ccc7f7ddda91db /NEWS.md
parentSetup variants for all allocating modules (diff)
downloadzg-10048b0d31d0db923ae39c6bbd67139ed6252f6f.tar.gz
zg-10048b0d31d0db923ae39c6bbd67139ed6252f6f.tar.xz
zg-10048b0d31d0db923ae39c6bbd67139ed6252f6f.zip
Allocation Failure Tests
These turned up an excessive amount of allocations in CanonData and CompatData, which have been reduced to two through the somewhat squirrely use of 'magic numbers'. There are now allocation tests for every allocated structure in the library, and they run to completion in a reasonable amount of time. So, that's nice.
Diffstat (limited to 'NEWS.md')
-rw-r--r--NEWS.md115
1 files changed, 101 insertions, 14 deletions
diff --git a/NEWS.md b/NEWS.md
index ca8308d..8a82bb9 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,24 +4,56 @@
4 4
5This is the first minor point release since Sam Atman (me) took over 5This is the first minor point release since Sam Atman (me) took over
6maintenance of `zg` from the inimitable José Colon, aka 6maintenance of `zg` from the inimitable José Colon, aka
7@dude_the_builder. 7@dude_the_builder. We're all grateful for everything he's done for
8the Zig community.
8 9
9As it's a fairly complex project, I'm adding a NEWS.md so that users 10The changes are fairly large, and most user code will need to be updated.
10have a place to check for changes. 11The result is substantially streamlined and easier to use, and updating
12will mainly take place around importing, creating, and deinitializing.
11 13
12### Data is Unmanaged 14### The Great Renaming
13 15
14This is the biggest change. Prior to `v0.14`, all structs which need 16The most obvious change is on the surface API: more than half of the modules
15heap allocation no longer have a copy of their allocator. It was felt 17have been renamed. There are no user-facing modules with `Data` in the name,
16that this was redundant, especially when several such structures were 18and some abbreviations have been spelled in full.
17in use, and it reflects a general trend in the standard library toward 19
18fewer managed data structures. 20### No More Separation of Data and Functionality
21
22It is no longer necessary to separately create, for example, a `GraphemeData`
23structure, in order to use the functionality provided by the `grapheme`
24module.
25
26Instead there's just `Graphemes`, and the same for a couple of other modules
27which worked the same way. This means that the cases where functionality
28was provided by a wrapped pointer is not provided directly from the struct
29with the necessary data.
30
31This would make user structs larger in some cases, while eliminating a
32pointer chase. If that isn't a desirable trade off for your code,
33read on.
34
35### All Allocated Data is Unmanaged
36
37Prior to `v0.14`, all structs which need heap allocation no longer
38have a copy of their allocator. We felt that this was redundant,
39especially when several such structures were in use, and it reflects
40a general trend in the standard library toward fewer managed data
41structures.
19 42
20Getting up to speed is a matter of passing the allocator to `deinit`. 43Getting up to speed is a matter of passing the allocator to `deinit`.
21 44
22This change comes courtesy of [lch361](https://lch361.net), in his 45This change comes courtesy of [lch361](https://lch361.net), in his
23first contribution to the repo. Thanks Lich! 46first contribution to the repo. Thanks Lich!
24 47
48### DisplayWidth and CaseFolding Can Share Data
49
50Both of these modules use another module to get the job done, `Graphemes`
51for `DisplayWidth`, and `Normalize` for `CaseFolding`.
52
53It is now possible to initialize them with a borrowed copy of those
54modules, to make it simpler to write code which also needs the base
55modules.
56
25### Grapheme Iterator Creation 57### Grapheme Iterator Creation
26 58
27This is a modest streamlining of how a grapheme iterator is created. 59This is a modest streamlining of how a grapheme iterator is created.
@@ -37,10 +69,65 @@ var iter = grapheme.Iterator.init("🤘🏻some rad string! 🤘🏿", &gd);
37Now: 69Now:
38 70
39```zig 71```zig
40const gd = try grapheme.GraphemeData.init(allocator); 72const graphemes = try Graphemes.init(allocator);
41defer gd.deinit(allocator); 73defer graphemes.deinit(allocator);
42var iter = gd.iterator("🤘🏻some rad string! 🤘🏿"); 74var iter = graphemes.iterator("🤘🏻some rad string! 🤘🏿");
43``` 75```
44 76
45You can still make an iterator with `grapheme.Iterator.init`, but the 77It remains possible to use
46second argument has to be `&gd.gd`. 78
79```zig
80var iter = Graphemes.Iterator.init("stri̵̢̡̡̡̨̧̡̨̡̡̡̨̫̗̗̱̳̼̖͚͉̩̬̬͚̟̣̮̬̙̖̗͇̮͓̻̫͍͎͉͎̹̩̗͖͈̙̻̭̝̭̼̙̯̪͚̙͉͎͎͖̥̹͈̫͍̹͓̘̙͎͖̝̦͎̤̼̹͕͈̪̙̪̯̯͙̝͈͕̬̪̗̭͎͖̟͚̦̣̘͙̞̮̹̙͚̼̤̟͉̭͔̩͍͔͈̯͎̘͎̭̥̖̜͙̖̖͍̼͙͎͚̦̮̹̞̺͍̳̖̹̼̲̠̩̰̳͂̌̈́̓̄͋̇̎͜͜͠ͅͅͅͅng", &graphemes);
81```
82
83If one were to prefer doing so.
84
85### Initialization vs. Setup
86
87Every allocating module now has both an `init` function, which
88returns the created struct, and a `setup` function. The latter
89takes a mutable pointer, and an `Allocator`, returning
90`Allocator.Error!void`.
91
92So those who might prefer a single-pointer home for such modules
93can allocate the struct on the heap with `allocator.create`, or
94add a pointer field to some other struct, then use `setup` to
95populate it.
96
97In the process, the various spurious reader and decompression errors
98have been turned `unreachable`, leaving only `error.OutOfMemory`.
99Encountering any of the other errors would indicate an internal problem,
100so we no longer make user code deal with that unlikely event.
101
102### New DisplayWidth options
103
104A `DisplayWidth` can now be compiled to treat `c0` and `c1` control codes
105as having a width. Canonically, terminals don't print them, so they would
106have a width of 0. However, some applications (`vim` for example) need to
107escape control codes to make them visible. Setting these options will let
108`DisplayWidth` return the correct widths when this is done.
109
110### Unicode 16.0
111
112This updates `zg` to use the latest Unicode edition. This should be
113the only change which will change behavior of user code, other than through
114the use of the new `DisplayWidth` options.
115
116### Tests
117
118Is is now possible to run all the tests, not just the `unicode-test` subset.
119Accordingly, that step is removed, and `zig build test` runs everything.
120
121#### Allocations Tested
122
123Every allocate-able now has a `checkAllAllocationFailures` test. This
124process turned up two bugs. Also discovered were 8,663 allocations which
125were reduced to two, these were also being individually freed on deinit.
126So that's nice.
127
128#### That's It!
129
130I hope you find converting over `zg v0.13` code to be fairly painless and
131straightforward. There should be no need to make changes of this magnitude
132in the future.
133