Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added representation of pointer types. #51
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
Added representation of pointer types. #51
Changes from 8 commits
13da89f
049dc62
ab527c7
872a405
be86083
db5f98d
e2e6f0a
45d6eee
7fb3b93
fc39320
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Question: if the length is zero, then what is
ptr
? Perhaps*const T
is a better choice -- certainly it will fit the "validity invariants" better (eg, I don't think there is any requirement that it be "dereferenceable" in the event that length is zero). However,from_raw_parts
does state:It seems worth linking to
slice::from_raw_parts
and reproducing some of that text (although arguably those are things best left for the next discussion?).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.
While I don't like the use of references here much [0] the guarantee here is that "the representation of
&[T]
is the same as ofSlice<T>
", - that is, theSlice<T>
struct only applies to the representation / layout of&[T]
and not to its validity.Ideally, we would use the same examples to show validity and representation, but we haven't settled the validity of these yet (it might well be that we need different "examples" for the
&[T]
and the*[T]
cases). I think it is worth it to wait until the validity of these is settled before trying to "unify" all the examples.[0] Personally, I don't like the use of
&T
here much, it has too many connotations, e.g., w.r.t. validity and safety, and we don't really care about them when just talking about the representation. It might be worth it to just say:The representation of
&[T]
is the same as that of:AFAICT there is no need to make
Slice<T>
generic sinceT: Sized
, but maybe there is something else going on here?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.
Like I said above, we could also use
and in practice,
N
andlen
are the same.All these defns are equivalent, it's just a case of which is the more human-readable.
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.
I added a comment that
*T
means*const T
or*mut T
when the mutability is unimportant, and used*T
rather than&T
. On zulip, @gnzlbg was okay with this, have we finally closed the last issue?