-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sentinel-terminated pointers #3728
Conversation
Does this mean that you can't do What does this mean for concatenating two strings? const a = "foo";
const b = "bar";
const c = a ++ b; // is this null terminated? do I end up with a null in the middle?
Are we going to end up with idea: instead of |
This implementation does not seem quite right. It gives impression of a hack. Not sure. Maybe there should be a type Also i like @daurnimator's idea: |
This code works in master branch and in this branch:
In the expression One of the main benefits of having null termination in the type system is that operations such as
Maybe you are onto something here, but please open a separate proposal. This is an implementation of the accepted-for-over-two-years proposal #265. |
[*]allowzero u8, [*]allowzero const u8, | ||
[*]allowzero volatile u8, [*]allowzero const volatile u8, | ||
[*]allowzero align(4) u8, [*]allowzero align(4) const u8, | ||
[*]allowzero align(4) volatile u8, [*]allowzero align(4) const volatile u8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need a extra bit of the test matrix here adding null pointers?
Not allowed, with the current implementation. error: type "E" has no null value, cannot be used in null terminated pointer. |
as well as `@typeInfo` and `@Type`
this also deletes C string literals from the language, and then makes the std lib changes and compiler changes necessary to get the behavior tests and std lib tests passing again.
974e44b
to
7597735
Compare
behavior tests passing now
A good update to make would be for |
Attempting this I got:
|
Removed C literals
This implements #265.
slicing sentinel terminated array or pointer withslicing sentinel-terminated array or pointer with..
as end index should give a sentinel-terminated slice..
as end index should give a sentinel-terminated slice #3766[N]null T
,[]null T
, and[*]null T
, with the syntax from make null terminated pointer syntax support any sentinel value, not just null #3731[:x]T
to[]T
[*:x]T
to[*]T
[N:x]T
to[N]T
*[N:x]T
to*[N]T
[:x]T
to[*:x]T
[N:x]T
to[:x]const T
[N:x]T
to[*:x]const T
#265
). (follow-up issue: Finish taking advantage of sentinel-terminated pointers in the standard library #3767)Look for regressions in zig community members' actively maintained projectsthere are already recent regressions such as error unions + optionals generating invalid llvm #3692 which are unrelated to this branch, so I'll be doing this in master branch in the upcoming week or two. Hold on to your butts.Remove type coercion from array values which do not have static lifetimes to referencesremove type coercion from array values to references #3768when comptime len index, reading gives comptime value. writing asserts the value is the sentinel, and is no-opmake null terminated pointer syntax support any sentinel value, not just null #3731 (comment)