|
|
|
|
|
by daxelrod
4665 days ago
|
|
> constructors should be as safe as they can be, which means no allocations, partial or not. Can you expand upon what you mean by "safe" here? If you mean "unable to fail", I vehemently disagree. Constructors should validate what is passed into them and fail if that is invalid. The alternative is to construct a zombie object that can't actually be used. Objects like this subvert the type system and lead to lots of unnecessary "if object.is_valid()" checks all over code that uses them. |
|