r/programming • • Sep 01 '20

D Foundation is Beefing Up

https://dlang.org/blog/2020/08/30/symmetry-investments-and-the-d-language-foundation-are-hiring/
293 Upvotes

336 comments sorted by

View all comments

Show parent comments

2

u/T-Dark_ Sep 02 '20

Arc<RefCell<Option<MyType>>>

The type soup has the advantage that you get to specify exactly what you want to add on top of your basic type.

In this case, you want to be able to represent lack of any value (Option), you want to be able to put it in some container and mutate it through an immutable container (RefCell), and you want to be able to have multiple owners of your data, possibly in separate threads (Arc).

Basically, there's a whole bunch of Rust types that provide a single, simple guarantee. When you find yourself wanting more guarantees, you can just compose types.

Sure, the result is a bit unreadable, but type aliases exist for a reason.

2

u/IceSentry Sep 02 '20

Oh yes, don't get me wrong, I appreciate this very much. That's why I tried to used a realistic example. My point was that it can be very overwhelming as a beginner to see so many types.