Stream: general

Topic: bikeshedding references terminology

Elichai Turkel (Dec 02 2019 at 09:13, on Zulip):

Currently in rust we call let ptr = &mut T a mutable reference to T. the reason AFAIK is mostly because that reference is unique, the reference is the "special" part here.
but in C it would be a const pointer to a mutable T.
this is all fine and good until we get to let mut ptr = &b and foo(mut ptr: &T).
how is that called? again in C that'll be a mutable pointer to a const T
in rust will this be called a mutable reference holding a T? something else?

cc @RalfJ

rkruppe (Dec 02 2019 at 10:53, on Zulip):

My solution is to clearly separate the place from the type. So I don't call let mut x: i32; a mutable integer, it's just an i32, if the mutability needs to be pointed out then I say it's a mutable variable. Likewise &T is just always a (shared) reference, and if I need to point out that a place of that type is mut, I word it so that the "mutable" is not adjacent to the type description but associated with the place that's mutable.

gnzlbg (Dec 02 2019 at 10:57, on Zulip):

I think similarly. Above ptr is just a place, containing an exclusive reference to a T. Whether the place is read-only or read-write is orthogonal to what it contains.

Last update: Dec 12 2019 at 01:35UTC