3 ms·
> think having min() return Either(int,error) is the way to go for most languages What about languages that want to be efficient? It's much more efficient to u
by diolang 6y ago
> think having min() return Either(int,error) is the way to go for most languages
What about languages that want to be efficient? It's much more efficient to use a int return value then to unwrap it. Efficiently is one of the main goals of this language (Efficiently, safety, syntax/readability)
- Someone 6y agoDo you think enforcing that lists never are empty is more efficient? If the language can prove the list is not empty, it can elide constructing that “Either” object and optimize away the caller’s error path. If it can’t (and there will be lots of cases where it won’t be able to, even though it theoretically could), what will it do? Return an incorrect value, abort the program, refuse to run the code, something else?
- diolang 6y agoYes. It's done during compile time and trivial to do. Changing the function signature is significantly harder. You'd either have to inline the function, evaluate the code, run optimizations to remove the Either wrapping or you can have a more specialize simple check and have two version of the function. One with the standard signature and one that doesn't use Either and modifies the function to not use it. Having one function signature which you don't need to modify is significantly more simple than applying several optimizations to undo wrapping and not break anything