Skip to content

Define "interior mutability" #32

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

Merged
merged 1 commit into from
Oct 25, 2018
Merged

Conversation

shepmaster
Copy link
Member

per @RalfJung..

at least in my mind, interior mutability is pretty much settled

@RalfJung
Copy link
Member

RalfJung commented Oct 8, 2018

Hm, I know it was me who said that but the "non-transitively" part is probably confusing. Might be better to remove this and instead mention that this stops at raw pointers.

Or maybe this is better explained by pointing out the pattern this violates? "Memory behind a shared reference is not mutated (transitively through references and boxes, but not through raw pointers)". If you do it anyway, (a) you need to wrap the memory being mutated (NOT the reference!) into UnsafeCell and (b) then you have interior mutability. Does that make sense?

@glaebhoerl
Copy link

(Maybe this is the wrong place to raise this but I've always wished we called this "shared mutability" rather than inventing our own terminology with "interior". "Shared mutability" is a concept already widely known outside of Rust, and AFAIA, its definition matches what we wish to denote by it within Rust. Also the shared mutability <-> shared references suggestiveness is nice.)

@avadacatavra
Copy link
Contributor

I would also prefer to call this "shared mutability." Personally, I associate interior mutability with using a Cell to mutate a field on a struct.

@RalfJung
Copy link
Member

@avadacatavra I am confused. I do not understand the distinction you are making between Cell in general and Cell to mutate a field on a struct.

@avadacatavra
Copy link
Contributor

@RalfJung ...now that I'm rereading this I'm not sure what was going on in my head...

I think that the definition in this PR confused me (and I was commenting at 1am which couldn't have helped)

@avadacatavra
Copy link
Contributor

Since the wider Rust community uses interior mutability, I consider it out of scope for this WG to change it to "shared mutability." I'm going to merge this and if we decide to refine the definition at a later date, then we can

@avadacatavra avadacatavra merged commit dabbc41 into rust-lang:master Oct 25, 2018
@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 26, 2018

Should we open an issue to track that? Whether it is in scope for this WG to change that, and whether it should be changed?

@shepmaster shepmaster deleted the patch-2 branch November 14, 2018 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants