4 ms·
> Go preaches that values should always be useful This is already false. Not all values are useful, for example, the value of this string is not useful to you:
by nulld3v 3y ago
> Go preaches that values should always be useful
This is already false. Not all values are useful, for example, the value of this string is not useful to you: "i have cheese".
Without knowing the caller, values can be "possibly useful" at best.
> Often they will be dependent for all practical purposes. It is not an unreasonable assumption to assume that they are, especially if you know the caller. However, Go believes you cannot make that assumption. That you have to let the caller determine what it finds useful, not what you think it might find useful.
In Go, functions always assume the caller needs both a valid value of T and error, even when T has no value. Functions should synthesize some value for T should T not currently have a value at return time.
In Rust, most functions assume the caller needs either a valid value of T or Error. Should a valid value of T exist at return time, it will be discarded.
Both languages make assumptions.
> Tradeoffs, as always.
Assumptions come with tradeoffs, however, not all tradeoffs are equal in consequence and possibility.
99% of the time, a caller does not need T if there is an Error. Therefore, why make this tradeoff?