Small poll

Luke Gorrie luke@REDACTED
Fri Dec 12 00:00:07 CET 2003

Kostis Sagonas <kostis@REDACTED> writes:

> Now let me tell you why I am interested in 3:
>   In the context of generating native code, it is really a nuisance
>   to have to handle all sorts of illegal combinations of arguments
>   to "basic" primitives like "+".  Moreover, in the case of HiPE,
>   because the compiler is (much) more sophisticated than the BEAM
>   one, it actually discovers quite a lot more cases of such errors.
>   Currently, we try our best to "immitate" the behaviour of the BEAM
>   compiler, but in sleepless nights like this one, I keep wondering
>   whether there should really be a limit to the level of naivety
>   one pretends to show, or shouldn't there be?

Another option would be "2.5". Suppose the function is:

  foo(A) ->
      X = a+42,

having detected the problem you could compile it as essentially:

  foo(A) ->
      throw({badarith, a, 42}).

Would that ease the compiler work any?

Some other compilers do exactly this. I know because once, due to a
type-inferencer bug, I got a message like:

  Error: 42 is not an integer.

because the compiler had wrongly convinced itself that a variable
could never be bound to an integer, but at runtime when the error was
generated it actually was :-)

More information about the erlang-questions mailing list