First Draft: cast(ref T)... as shorthand for *cast(T*)&...
IchorDev
zxinsworld at gmail.com
Tue Jan 21 21:47:24 UTC 2025
On Monday, 20 January 2025 at 23:11:46 UTC, Walter Bright wrote:
> On 1/20/2025 2:07 AM, Juraj wrote:
>> We now have local `ref`, and that makes this syntax a
>> cognitive burden.
>
> Think of `cast(ref int)f` as "refer to `f` as if it were an
> `int`" and it will make perfect sense.
I agree that the syntax is confusing.
When I see `cast(ref T)` I think it’s like `__rvalue` in reverse:
allowing you to forcibly allow ref to bind an rvalue. In fact,
I’d prefer that meaning for `cast(ref T)` (or `cast(ref)`) since
it’s intuitive.
What about `cast(in T)` instead? As in ‘re-INterpret’. `in` also
doesn’t make sense for local variables, so it actually reads as a
different use of the keyword.
More information about the dip.development
mailing list