Coffeehouse Post

Single Post Permalink

View Thread: is managed code faster than native?
  • User profile image
    evildictait​or

    , Bass wrote

    @evildictaitor:

    Can you point out a situation where type inference can't tell what a type would be, but a programmer can?

    function  add(var1, var2) { return var1 + var2; }

    alert(add(1, 2)); alert(add("1", "2"));

    In this case, add will be implemented by a call, not by an ADD because two type inference passes will come back with different types.

    If this was done via a C++ template the first time will be an ADD opcode for integer addition and the second one will be done by a call to a string concatenation routine.