First Draft: cast(ref T)... as shorthand for *cast(T*)&...
Dukc
ajieskola at gmail.com
Tue Feb 25 12:46:53 UTC 2025
On Saturday, 18 January 2025 at 07:31:40 UTC, Walter Bright wrote:
> Proposed by Manu https://github.com/dlang/dmd/issues/20644
>
> PR: https://github.com/dlang/dmd/pull/20728
I agree with Dennis in the GitHub thread. Reinterpret casts are
pretty extreme hacks. `*cast(T*) &` is a good syntax for this one
because it clearly shows how the hack works and is so ugly that
we don't feel tempted to use it when it's not needed. This is no
place for syntactic sugar IMO.
If anything, we want a library helper function like Paul
suggested, but I'm slightly reserved even about that. When doing
reinterpret casts, it's extremely important to understand exactly
how the cast works. Any abstraction over that always tends to
more or less hide it.
More information about the dip.development
mailing list