erlc question, why no error message for erronous code?

Joe Armstrong <>
Tue Jun 3 13:15:33 CEST 2003


But it's not an error.

  catch (rate_class + 1)

is well defined

Now why anybody might want to write that is a mystery - but it it allowed

(A warning might be better  - oh and a pragma to turn off the warning)
then you could write

   X = catch ( (yesIknowItlooksFunny) rate_class + 1)

Many years ago I was programming some hardware - I wanted to send
an illegal command to the hardware.

The software would not allow this. I asked the compiler writer why I could not
send a op code 23 to the hardware - he said "you can't it's illegal"

  I said  - "but I want  to test the hardware  - see if  the red light
goes on when you send it an illegal command"

  He said, "you can't send an illegal command to the hardware"

  So I had to /dev/null his compiler and re-write the thing so I could do
what I wanted.

So from then on I was of the opinion that a compiler should allow anything
even if it looks silly *provided* it is well-defined and safe.

and thus it was :-)

/Joe


On Tue, 3 Jun 2003, Bengt Kleberg wrote:

> greetings,
> 
> i had a (runtime) crash with ''badarith''. the code was:
> rate_class + 1
> 
> while not beeing a compiler writer, i somehow think it would be
> possible for the compiler to diagnose this kind of error*, would it
> not?
> 
> *i belive this is a ''attempt to do arithmetic on an atom'' kind of error.
> 
> 
> bengt
> 




More information about the erlang-questions mailing list