std: replace mem.Allocator.dupeZ and mem.orderZ with *Sentinel versions#25290
std: replace mem.Allocator.dupeZ and mem.orderZ with *Sentinel versions#25290IOKG04 wants to merge 4 commits intoziglang:masterfrom
mem.Allocator.dupeZ and mem.orderZ with *Sentinel versions#25290Conversation
|
I agree that having more flexibility is a good thing, but I disagree with deprecating the *Z methods simply because null-terminated arrays are overwhelmingly more common compared to anything else. Forcing everyone to adapt their usages feels like prioritizing some kind of theoretical flexibility over well-established usability. |
|
I too would say that
|
Just my 2c, maintainers have to decide, but so far I've seen "one obvious way" to mean "one easily-decidable way", not "only one way at all". As another example, |
|
The advice I was given was that The Zig Zen is descriptive, not prescriptive. Thus, you should avoid arguments that cite or reference it. Code should stand on it's own merits and it's own arguments, if the only rational or reason for a change is "it feels more like the zig zen to me" it really has no compelling reasons at all. In this case, while I would have preferred |
c917ff5 to
d165f17
Compare
Similarly to what #25260 did with
fmt.bufPrintZ, I replacedmem.Allocator.dupeZandmem.orderZwith more genericSentinelversions, so they can be re-used more.Since most of the
*Zfunctions are there to interact with the operating system/c code (ex.posix.mkdirZ), I didn't change those.One I did consider changing was
mem.joinZ, though in my opinion it'd be worth completely reworking it (andmem.join), so it doesn't only work on[]u8s, but on any slice type.I can do that in this PR too, though some help for naming would be appreciated, cause the
joinfunctions as they exist currently should be kept and just marked deprecated, but the new, generic functions should also have fitting names.closes #25285
also fixes one of the issues described in #22618