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

Dom DiSc dominikus at scherkl.de
Wed Jan 22 23:50:21 UTC 2025


On Wednesday, 22 January 2025 at 19:17:06 UTC, Paul Backus wrote:

> language spec about how `cast(S) expr` can be rewritten to 
> `S(expr)` if S is a struct. [5]

> Burying this feature in the specification for cast expressions 
> would be, IMHO, a great way to ensure that hardly anybody ever 
> finds out about it.
>
> [5] https://dlang.org/spec/expression.html#cast_struct

I would use this much more often, if only it would work also with 
basic types. But I tend to write as-generic-as-possible code. If 
something works only for some types, it's most often completely 
useless. I'm much better off remembering only the way that works 
for every type.


More information about the dip.development mailing list