First Draft: cast(ref T)... as shorthand for *cast(T*)&...

Dukc ajieskola at gmail.com
Tue Feb 25 19:14:00 UTC 2025


On Tuesday, 25 February 2025 at 17:06:31 UTC, Paul Backus wrote:
> The pointer used in these casts is a language-level abstraction 
> that doesn't actually exist at runtime. If you look at the 
> generated assembly, it's just a `mov` instruction.

This is just a compiler optimisation. The critical thing to 
understand in this case is what happens semantically at the type 
level.

Still, it's a matter of taste. There's no fundamental reason why 
`*cast(T*) &` would be any more transparent to the user than 
`reinterpretCast!T`, it's just how I feel.


More information about the dip.development mailing list