> For a more typical PHP example, getUser(int $id) is not a total function, > unless you have PHP_MAX_INT user objects defined in your database. If you > pass an int that does not correspond to a defined user, you now have to deal > with "user not found" error handling. getUser() is not a total function. > getUsers(array $criteria), however, arguably is, because it's logical and > reasonable to map all not-found cases to an empty array/collection, which > doesn't require any special error handling.
getUser() could return a nullable type. But totality assumes purity, and I'm assuming you didn't hard-code all users inside the getUser() function. :) As soon as you interact with the outside world, you can have exception and errors, and thus you can't guarantee termination. In any case, I think the concept of totality is pretty foreign to PHP, and we can probably leave it behind (you'd have to make sure - statically, in the type-system - there are no infinite recursion, no infinite loops, ...). Olle -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php