-
Notifications
You must be signed in to change notification settings - Fork 11
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
Null termination issues in StaticString #2
Comments
Ah, these are good questions. Fixing The big question is whether we should try to be more consistent with including null termination or if we should try to eliminate it altogether. In principle, dropping it would be great -- because it'll be hard to have getindex return maximally efficient views / substrings if we have to append. In practice, it may be tricky, since even LLVM is in practice expecting strings to be null-terminated (i.e., can't use We could maybe get around that by only ever using And, while Julia strings are officially "not" null-terminated, in practice they actually are every time I've checked, i.e.:
|
My initial reasoning for including null-termination in |
Also: hooray, first issue 🎉 |
One option may be to have |
Null termination for output is a good consideration. But, we could add the null termination prior to passing to output functions. I don't think Regarding Also, I see that Semi-relevant Julia issues: JuliaLang/julia#10994, JuliaLang/julia#16731, JuliaLang/julia#7036 |
Yeah, WIP here: https://github.com/brenhinkeller/StaticTools.jl/tree/refactor-strings That'll make |
So just an update on the current status of this:
We still differ from Base, however, in including the null termination in What do people think, should we change those to hide the null termination as well? |
Given no objections, I'm going to go ahead and close this as completed, but feel free to restart the discussion if it seems like we should go farther! |
Here are some notes:
getindex
doesn't add a null termination as noted in a comment.display
is broken without null termination. Maybe this should uselength
instead of the termination.length
should beN-1
and not count the null at the end.codeunits
include the termination? It doesn't for a String.Could the null termination be removed? I don't think Julia strings need it.
The text was updated successfully, but these errors were encountered: