News for hackers. Stuff that matters.
Re:The use of `class` for things that should be simple free ... by josephcsible on Thursday May 28, 2020 @01:58PM (#23340304)
That's actually an argument in favor of linear or affine types. In your example, you'd still get a new Wallet from that function, but the compiler would keep you from accidentally using the old one afterwards. That way, you can't make that mistake, but still get the benefits of immutability.
Re:The use of `class` for things that should be simple free ... by cessor on Friday May 29, 2020 @05:12AM (#23347894)
I will admit that I don't know what "linear types" or "affine types" are. Your answer makes me feel like I am trying to convey an idea for which you have the perfect formalism / meta vocabulary. It might be that objects, or at least the way that I know how to use them in my favorite languges, are just a (potentially limited) implementation of said formalism.

I feel that objects offer a flexibility benefit though (which is why they often elude formal approaches) for the cost of purity.

Re:The use of `class` for things that should be simple free ... by josephcsible on Friday May 29, 2020 @10:56AM (#23350643)
Rust is probably the most mainstream language that uses affine types. Once you call a function that takes ownership of a value (e.g., `drop`), the compiler won't let you use it anymore after the function call.