Why don't you throw an exception instead of returning random things that
are not accurate?

It makes the response of the operation or casts more realistic, since you
will never get INF or NAN as result and possibly transform it to 0
unconsciously. It will keep the semantic for expected types, for example, a
division of 2 integers can result in a integer or float, but never boolean.

Exceptions are there since PHP 5 and it is largely used by frameworks and
developers. It is not a new or not used concept. I guess using them bring
more value to the language than keeping the "lets define a default value
for this case and worry about the other cases later". It just adds more
confusion to developers to know if certain things returns 0, false, -1, etc
for all different functions/operations across the language.


Juan Basso

Reply via email to