Comment

Comment by Animats

I tended, in my C++ days, to think that if you need "reinterpret_cast", you're doing it wrong. Now that I code in safe Rust, I still think that.

If you really want to abstract this sort of thing, a good abstraction would be a write-only type, "space", representing memory with no content. Then make it possible to destroy an object and convert it to empty "space", or construct an object on empty "space". This creates a clear distinction between reusing memory and abusing the type system.

parent Animats 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton