mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
23b7d28896
These functions are currently footgunny when working with pointers to arrays and slices. They just return the stated length of the array/slice without iterating and looking for the first sentinel, even if the array/slice is a sentinel terminated type. From looking at the quite small list of places in the standard library/compiler that this change breaks existing code, the new code looks to be more readable in all cases. The usage of std.mem.span/len was totally unneeded in most of the cases affected by this breaking change. We could remove these functions entirely in favor of other existing functions in std.mem such as std.mem.sliceTo(), but that would be a somewhat nasty breaking change as std.mem.span() is very widely used for converting sentinel terminated pointers to slices. It is however not at all widely used for anything else. Therefore I think it is better to break these few non-standard and potentially incorrect usages of these functions now and at some later time, if deemed worthwhile, finally remove these functions. If we wait for at least a full release cycle so that everyone adapts to this change first, updating for the removal could be a simple find and replace without needing to worry about the semantics. |
||
---|---|---|
.. | ||
compiler_rt | ||
docs | ||
include | ||
init-exe | ||
init-lib | ||
libc | ||
libcxx | ||
libcxxabi | ||
libunwind | ||
std | ||
tsan | ||
build_runner.zig | ||
c.zig | ||
compiler_rt.zig | ||
ssp.zig | ||
test_runner.zig | ||
zig.h |