On Sun, Apr 25, 2021, at 2:04 AM, Olle Härstedt wrote: > > A total function is a function that is defined over the entire domain of its > > inputs. For example, addition is a total function over integers, because > > for every possible pair of integers you pass to it there is a logical return > > value. However, square root is not a total function over integers because > > there are some integers you pass it for which there is not representable > > return value. (Negative numbers, unless you get into imaginary numbers > > which PHP doesn't support.) In those cases, you have to throw an exception > > or return an error code or similar. > > Maybe nitpicking, but PHP-land shouldn't make up their own > definitions: "A total function is a function that is defined for all > possible values of its input. That is, it terminates and returns a > value." > https://softwareengineering.stackexchange.com/questions/334874/in-the-context-of-functional-programming-what-are-total-functions-and-partia > > Which means a total function is guaranteed to not have any errors, > like exceptions or division by zero. Compare with languages F* or Koka > which support this notation.
That... is literally what I said. There was no making up definitions. I was using the actual mathematical definition. PHP is quite capable of having total functions, they're a good thing, and we should try to encourage them where feasible. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php