Date: Sat, 8 Feb 2025 13:42:56 +0000
On Sat, 8 Feb 2025 at 13:34, Jonathan Wakely <cxx_at_[hidden]> wrote:
>
>
> On Sat, 8 Feb 2025 at 13:22, Sebastian Wittmeier via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> Go and Rust use * for dereferencing.
>>
>>
>>
>> https://go.dev/tour/moretypes/1
>>
>
> Even though there is no pointer arithmetic, and therefore no chance of
> misunderstanding what `p + 2` means, it looks like you still need to say
> `*p + 2`, i.e. no implicit dereferencing of pointers to act on the pointee.
>
>
>>
>> https://doc.rust-lang.org/book/appendix-02-operators.html
>>
>>
>>
>> Rust uses (*p). to access members of pointed to objects in unsafe mode.
>>
>
> Again, no implicit dereferencing. It looks like you need to use `(*p).i`
> rather than just `p.i` to access a member through a pointer.
>
> So while it's true that they don't have -> for dereferencing pointers,
> they are not arguments in favour of using . to dereference pointers. You
> could use them as arguments for getting rid of -> because we can just do
> `(*p).i` instead, but I don't think anybody wants that!
>
>
And of course, if C and C++ would still require things like `(*p)[n]` in
some situations, then removing the need for -> would not mean that users
don't have to understand what a pointer is and what dereferencing it does.
It would only affect member access expressions through pointers, while
still leaving all the other properties of pointers unchanged. That doesn't
seem like it would really help beginners or people struggling with the
semantics of pointers.
>
>
> On Sat, 8 Feb 2025 at 13:22, Sebastian Wittmeier via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> Go and Rust use * for dereferencing.
>>
>>
>>
>> https://go.dev/tour/moretypes/1
>>
>
> Even though there is no pointer arithmetic, and therefore no chance of
> misunderstanding what `p + 2` means, it looks like you still need to say
> `*p + 2`, i.e. no implicit dereferencing of pointers to act on the pointee.
>
>
>>
>> https://doc.rust-lang.org/book/appendix-02-operators.html
>>
>>
>>
>> Rust uses (*p). to access members of pointed to objects in unsafe mode.
>>
>
> Again, no implicit dereferencing. It looks like you need to use `(*p).i`
> rather than just `p.i` to access a member through a pointer.
>
> So while it's true that they don't have -> for dereferencing pointers,
> they are not arguments in favour of using . to dereference pointers. You
> could use them as arguments for getting rid of -> because we can just do
> `(*p).i` instead, but I don't think anybody wants that!
>
>
And of course, if C and C++ would still require things like `(*p)[n]` in
some situations, then removing the need for -> would not mean that users
don't have to understand what a pointer is and what dereferencing it does.
It would only affect member access expressions through pointers, while
still leaving all the other properties of pointers unchanged. That doesn't
seem like it would really help beginners or people struggling with the
semantics of pointers.
Received on 2025-02-08 13:43:12