On Monday, 30 September 2013 at 14:08:12 UTC, Dicebot wrote:
On Monday, 30 September 2013 at 14:00:10 UTC, Chris wrote:
It would be nice, if someone with experience wrote a short article / tutorial about when to use structs and when to use classes, where the pitfalls are etc.

I don't think there is a common consensus here. Don't even think it is possible. Doom of proper multi-paradigm language :)

Well, if people shared their experience with ranges / structs vs. classes, it would be a good reference point for other programmers. There might not be any real rules, but rough guidelines would help, e.g. "If you want to achieve X, structs are better, because blah blah. But if you want to do Y, there might be a problem with structs. Better use classes." Maybe structs are better suited for parallel processing and multi threading (value vs reference), or maybe not? Just a collection of little hints would make life simpler. I'm sure someone has shot him/herself seriously in the foot using either structs or classes.

I use structs mainly for a. formatting and reformatting (I/O) and b. data storage. Classes I use for the overall logic of the program (with the usual suspects like controller, model, proxies ...) But I'm always willing to learn new tricks (this dog is not too old yet!).

Reply via email to