The first time I saw this wording in this thread I thought I was misreading, but from repetition and context here I must conclude: is this proposal really that x.y
, which so far always evaluates to a place, should instead evaluate to a pointer value if x
is a raw pointer?
Let me try to clarify by giving some example that highlight the difference.
*x.y = ...;
would involve different amounts (and kinds) of memory indirection depending on the types involved -- for example, it might write to a field of the memory pointed to byx: *mut Foo
, or it might through the pointery: *mut Bar
stored in the memory pointed to byx: &mut Foo
.- Consider the idiom for swapping two fields of a struct that you own or hold a reference to:
mem::swap(&mut x.field1, &mut y.field2)
-- ifx
is a raw pointer instead, then this would rather silently swap two temporary raw pointers (which has no effect). - (More examples involving longer place expressions occur to me but they depend on further details, e.g., would this syntax "auto-deref" through raw pointers?
It's probably easy to tell that I picked these examples "adversarially", that is, to illustrate what I believe to be an evident flaw of the proposal as I understood it. But these differences haven't been brought up at all as far as I saw, so I wonder whether I've misunderstood?