-
Notifications
You must be signed in to change notification settings - Fork 13.3k
decide on official naming conventions for ~, @, & and * #6608
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
Comments
IMHO:
IOW the name "pointer" would be reserved for pointers in the C sense. This is consistent with other languages I'm aware of (such as D), where the word "pointer" inherently carries the connotation of being unsafe, and the safe part of the language is distinguished by not having them. |
I think it's almost misleading to call Anyway, I kind of like the "owned"/"shared" dichotomy, and it's not really inaccurate to say that "Reference" feels weird. Calling it a reference more clearly delineates it from ~/@ but the "borrowing" verbage is probably not going anywhere in either case, so it might as well stay in the name, and "borrowed" fits in nicely with "owned"/"shared". I like "unsafe pointer" because it conveys that you're on your own with regards to convincing yourself that it's okay to dereference it. "Raw" doesn't really imply much beyond maybe not being as fully-featured as the other, cooked pointer types, but "unsafe" sort of suggests that you get to do all that uninhibited offsetting and casting and whatever you might feel the need to do as a C programmer without the compiler looking over your shoulder. Though if we end up calling all the other ones something besides pointer, that's moot. Sorry, that's a bit rambling, but I felt like I needed to get my two cent in before this bikeshed departs for good. |
(FWIW if you wanted to refer to just the handle of the box I would say owned/owning/unique and managed reference. "Reference" is to distinguish it not from |
I'd (weakly) vote against |
My vote:
|
+1 to the unique, managed, borrowed and unsafe qualifiers. |
By the way the reasoning beyond the suggestion to use |
Bumping for bug triage, this is still inconsistent across the documentation. |
My vote:
Hopefully moving |
The terminology that has won me over is:
|
This is too out-of-date to be relevant. Managed pointers are no longer part of non-gated language, and |
…ansch Add a note to `as_conversions` I have seen a couple of examples where there are some misunderstandings of `as_conversions` ([1](rust-lang/rust-clippy#5890 (comment)), [2](rust-lang/rust-clippy#6116 (comment)) and [3](rust-lang/rust-clippy#6428)). This PR adds the note that explains its purpose and relationship with other `as` related casts. Open question: should I list every related lints for discoverbility, or just suggest how to find these? I chose the former because there's no way to list only and all `as` related lints (e.g. on All the Clippt Lints, 'cast' includes some noises, but `cast_` excludes some) even though I cannot guarantee the list will be updated to include future changes. --- changelog: Add a note to the document of `as_conversions`
We use really inconsistent naming at the moment: unique/owned/managed pointers/boxes, borrowed/region pointers, unsafe/raw pointers.
Some thoughts on the possibilities:
&:
ref
andref mut
~ and @:
Owned/managed pointer isn't correct since the pointer itself is just a handle - all pointers are owned, but not necessarily what they point at. That's part of why we got into the convention of calling them boxes.
So we should settle on one of these:
*:
I think I would be happiest with "reference", "unique pointer", "managed pointer" and "raw pointer" but I'm sure there are other opinions :). I just want to get the documentation consistent with standardized terms....
The text was updated successfully, but these errors were encountered: