Skip to content

"Const" is confusing #3529

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

Closed
jruderman opened this issue Sep 18, 2012 · 5 comments
Closed

"Const" is confusing #3529

jruderman opened this issue Sep 18, 2012 · 5 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Milestone

Comments

@jruderman
Copy link
Contributor

In Rust, const means several things:

I think const pointers are the most confusing and should be renamed to something else (perhaps read pointers). This confusion may have contributed to the unsoundness fixed in 5d540de#L7L1206

@catamorphism
Copy link
Contributor

I also think const is confusing (I'm not a C++ programmer, and expect it to mean "constant"). I'm in favor of changing it to something less confusing.

@nikomatsakis
Copy link
Contributor

I agree. I think using const to mean both immutable and read-only is asking for confusion. The distinction is subtle as it is. I'd be happy with most anything. Maybe even &mut? T. :)

@brson
Copy link
Contributor

brson commented Sep 20, 2012

Will we still need const pointers when vector interiors can no longer be explicitly mutable?

@bblum
Copy link
Contributor

bblum commented Sep 21, 2012

I believe const pointers are still an important part of borrowck. AIUI, if you write a function that takes a &T, purity gets involved if you want to call it when what you have is a &mut T. But if the function can be written to take a &const T, it can be called more easily / in more cases(?).

Maybe the thing it makes most sense to rename is const-the-kind, the one that means "no mutable fields inside". It is kind of like send/owned in that regard ("The type structure does not have this thing inside it").

@graydon
Copy link
Contributor

graydon commented Mar 25, 2013

At this point I believe we're down to just the kind/trait; closing as fixed-ish. Reopen if you feel it's still confusing.

@graydon graydon closed this as completed Mar 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

6 participants