3 ms·
> But in realistic use cases for max, I want to assume that it produces a finite number, and if the inputs are integral, I expect an integer to pop out. But th
by pron 2y ago
> But in realistic use cases for max, I want to assume that it produces a finite number, and if the inputs are integral, I expect an integer to pop out.
But that's his point. You're talking about a concrete concern about code, whereas he says that first you should think in abstractions. Negative infinity helps you, in this case, to think in abstractions first.
- fc417fc802 2y agoAre the integers not a reasonable abstraction though?
- pron 2y agoThey could be, but using -∞ makes the abstraction simpler, and it's easy to map -∞ to an error when showing the conformance of the implementation to the abstraction.
- sevensor 2y agoThat’s my point though. Infinity isn’t useful for computation in a lot of cases where numbers are called for and it’s debatable that it even is a number. So it’s already a special error value, and if that’s the case, why use a value that accidentally behaves like a number sometimes?
- pron 2y agoBecause you're not writing a program. You're writing an abstract algorithm and this makes the algorithm slightly simpler to express without losing anything. If you don't like that, you can use a special error value instead even in your abstract description.