RfC for language feature: rvalue struct

FeepingCreature feepingcreature at gmail.com
Tue Jan 31 07:37:25 UTC 2023


On Tuesday, 31 January 2023 at 07:31:58 UTC, FeepingCreature 
wrote:
> And this is important because this idiom is inescapable, it 
> will always crop up (all over std.algorithm causing compile 
> errors for our immutable structs, cough), and in fact I 
> increasingly think it's just *good.* It's an inherent part of 
> D's C heritage.

Just to give an example, `maxElement` is actually straight up 
impossible to implement for every type without either of:

- `rvalue struct replacing `immutable struct`
- const range API (`typeof(this) next()` rather than `void 
popFront()`)
- rebindable structs in Phobos (librebindable)
- mandatory tail recursion at every optimization level.

None of which D has.



More information about the Digitalmars-d mailing list