in reply to Re^10: Strong typing and Type Safety.A multilanguage approach (implicit)
in thread Strong typing and Type Safety.A multilanguage approach

How can you coerce the choice of operators if the operator is monomorphic?

I have no idea what you mean. The evaluation of the operands coerces an SV to an IV, of course.

implicit conversion

I don't understand this logic. How is explicitly using a monomorphic operator which operates on numeric values any less explicit than performing a manual conversion operation through a method?

(I don't accept the "But it's easy to make a typo when using an operator!" argument because it's easy to make a typo when calling a method.)

  • Comment on Re^11: Strong typing and Type Safety.A multilanguage approach (implicit)

Replies are listed 'Best First'.
Re^12: Strong typing and Type Safety.A multilanguage approach (implicit)
by ikegami (Patriarch) on Nov 22, 2010 at 08:34 UTC

    How is explicitly using a monomorphic operator which operates on numeric values any less explicit than performing a manual conversion operation through a method?

    The addition operator operators on scalars, not numeric values; you can pass it a string if you so desire. The operator must coerce the string into a number in order to do the addition.

    The latter is explicit by definition. "Manual" is synonymous with "explicit".

    Implicit conversion is less explicit than explicit conversion.

      The addition operator operators on scalars, not numeric values; you can pass it a string if you so desire. The operator must coerce the string into a number in order to do the addition.

      From perlop:

      Binary "+" returns the sum of two numbers.

      The operator is monomorphic. Again, how is using the binary numeric addition operator not explicit about the intention to treat its operands in a numeric fashion?

        Monomorphic has nothing to do with it. You can have monomorphic operators that don't do any conversion (e.g. add), and you can have monomoprhic operators that do (e.g. to_int, +).

        You said yourself the addition operator coerces. What else is there to say.

Re^12: Strong typing and Type Safety.A multilanguage approach (implicit)
by ikegami (Patriarch) on Nov 22, 2010 at 08:31 UTC
    ok, it seems I had the wrong definition for coercion. According to wikipedia, "coercion" is simply another way of saying "implicit conversion" ("in most languages", it adds).