Open skyqrose opened 1 year ago
Generally if we want named args, we use a record. {lhs, rhs, epsilon}
or similar.
That said, I personally am against adding this function. If someone is going to compare floats, they should be required to think about how they want to do it. This is such a simple function to write out, that I think it is better explicit in user code. Not to mention, Dec
is planed to become the default Frac
type, and it has ==
. So for many users, this function should not be needed.
As a direct example, If I were to use this at work while comparing the output of an ML model before and after optimizations, it would either have to have such a large epsilon that it is useless, or it would constantly fail and have false positives.
EDIT: this may be best discussed on zulip in the ideas stream: https://roc.zulipchat.com/#narrow/stream/304641-ideas
The standard way to compare two
Frac
s is to check if their absolute difference is lower than some epsilon. This could be a builtin function.(There's probably a better name than this, though.)
Pros:
==
of Fracs. Patches over what would otherwise feel like a hole in the language.Cons:
See also: Issue about better compile errors for when you
==
two Fracs, which suggests the absolute difference approach, and could instead suggest an easier to use builtin function. https://github.com/roc-lang/roc/issues/5454