-
Notifications
You must be signed in to change notification settings - Fork 59
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
Layout of arrays #94
Layout of arrays #94
Conversation
Closes rust-lang#91 .
I think this can be ordered better, to be more understandable:
Giving the hypothetical example where |
I don't think this chapter should at all try to accomodate hypothetical future language extensions that allow array stride to differ from the size in other contexts. Besides all the reasons that it's unlikely to ever happen (backcompat hazards, massive churn, questionable gains [1]), writing for this hypothetical future complicates the wording of the layout documentation and it seems difficult to adequately describe that future without being misleading about or distracting from the status quo. It's also far from obvious to me what terminology would be used if it ever comes to that, so however we described it now might turn out to be "wrong" in the future. For example, it seems equally plausible that the current I am also concerned that if this text distinguishes [1]: the gains are questionable because small types benefit the most from nixing padding, but those same types also benefit from being padded to word alignment so they can be accessed with fewer loads/stores. |
Can't one construct a two element array and measure the pointer offset in bytes? That would be a super annoying thing to do, but is there a case where this is not possible? |
Hm, you're right, that should work (even in constant expressions) eventually. But I think it'll be so annoying and niche that nobody will bother and so the backwards compatibility problem of introducing stride != size would increase further. |
Sure, like, if somebody wanted to implement or propose this in a more proper form, I'll expect them to add an I think here we want to document what we currently guarantee without forbidding future work on that area (EDIT: at least until these issues are closed), but at the same time documenting how things currently work. |
I don't have a problem with leaving open the possibility of such future changes in some way, I think the current write-up is acceptable if we really want to refuse closing any doors. However, at the same time, I'm sad to put this extra mental burden on unsafe code authors when any such proposal will most likely either die from multiple contradictory backwards compatibility constraint or have to come up with a whole new and weird taxonomy of layout anyway. |
Looks good, thanks! |
@ubsan read this as well and found it ready. We can always amend this in subsequent PRs. |
Rendered.
Closes #91 .