RfC for language feature: rvalue struct

FeepingCreature feepingcreature at gmail.com
Mon Jan 30 15:21:02 UTC 2023


On Monday, 30 January 2023 at 14:43:21 UTC, Dukc wrote:
> I feel you use D very differently than I do. I bump to these 
> issues rarely enough that I don't feel bothered at all to write 
> getters when I do. Plus I consider the struct itself (and rest 
> of the module) being able to modify the field mostly a good 
> thing. I wonder how people feel in general. If your style is 
> widely spread, there might indeed be a case for a language 
> feature.

That's fair. We're coming at D like it's a functional language at 
heart with mutability bolted on, rather than a mutable language 
which can borrow some functional idioms. See my 2019 DConf talk 
https://www.youtube.com/watch?v=nKMOFaAdtAc ; the basic summary 
of how we use the language still holds.

The key insight is that we treat D like a functional language at 
the domain level, like an object-oriented language at the 
application level, and autogenerate everything at the 
infrastructure level. Almost all our structs live at the domain 
level, meaning they don't actually own state, they just represent 
domain knowledge. State-ownership happens at the application 
level, ie. in classes.

I do feel like `std.algorithm`, `std.functional` and ranges in 
general invite this sort of pure-data modelling though.



More information about the Digitalmars-d mailing list