4 ms·
> and a replacing it with a function that returns the same values for the same arguments will be safe No. That is only safe at compile time but not at runtime.
by holri 6y ago
> and a replacing it with a function that returns the same values for the same arguments will be safe
No. That is only safe at compile time but not at runtime.
Because the type alone often does not guarantee the meaning and semantics of the values in the specific context and program are the same.
- Asraelite 6y agoI'm not sure I get the argument here. So long as the input-output mapping for the function is identical, it cannot change the benavior of the program. This is what I would consider safe. The semantics of values are irrelevant because the function will behave identically regardless of those semantics.
- holri 6y agoThis only true if the type describes the whole meaning of the values. If the exit code of a unix program changes from 0 to 1 it still returns an int, but the meaning of that value is completely different one.
- Asraelite 6y agoBut the exit code can't change from 0 to 1. For any given input to the Unix program, if the output was 0 with one implementation, then it would always remain 0 with any other _equivalent_ implementation. This is literally what is meant by "returns the same values for the same arguments". Any function that fits this description, by definition, cannot suffer from the problem you are describing.