Re:Dark side of ergonomics in Rust
by golergka on Saturday April 14, 2018 @01:18PM
(#16838272)
The problem is that you can have half-initialzed objects at all. I don't know Rust very well yet, but in a typical OOP language it's a constructor's job to completely initialize an object, and exception in constrctor causes object to not be created at all.
[ Parent
| on HN ]
Re:Dark side of ergonomics in Rust
by steveklabnik on Saturday April 14, 2018 @01:22PM
(#16838291)
Rust does not have constructors as a language feature like that, and you must fully initialize objects, unless you use unsafe.
Wouldn't you want, in a similar manner, a single create() call to be responsible for full initialization? An API that makes it possible to have entities half-initialzed looks like a design mistake to me. If an initialization is long and requires a lot of parameters, I personally split a "config" object that has easy access to all of them and the "real" object that swallows it in constructor or "create" call all at once.