Small poll

Robert Virding robert.virding@REDACTED
Tue Dec 16 09:08:18 CET 2003


I have read through the discussion on this suggestion and found it a little strange, to say the least.

There are a few points I would like to make:

1. If I understood Richard correctly he means that the compiler should be careful when it can't do things consistently, in this case warn about a a construction which will generate an error. He also gave some equivalent code to "a+42" which the compiler would not warn about. His first case, "X = a, X+42" is especially funny as the compiler will generate exactly the same code for it, as it has some simple constant propagation in it. I completely agree with Richard.

2. As Dr. Joe (again congratulations Joe) points out "a+42" IS LEGAL ERLANG! Sorry for shouting but the point must be stressed. How can any one seriously suggest that the compiler disallow legal code? You are actually changing the semantics of the language when you do this. Are you aware of this fact?

3. What is the point is the compiler transforming it to exit({badarith,...})? What are you exactly gaining by doing it? Not saving code anyway, and hardly runtime either. 

So my suggestion would be #2, generate a warning. I say that the compiler should disallow illegal code and allow all legal code while warning for potentially stupid things. It should NEVER disallow legal code. Sorry Bjorn but this also includes a compiler option which transforms all warnings to errors. Do you seriously mean that it should be illegal to have singleton variables, unused functions, bad calls to format etc? It is one thing to warn, but to disallow?

The compiler should help me and not hinder me by trying to be too stupidly smart. As example just look at what Word/Outlook Express do for some really terrifying examples. This is somewhat similar to the syntax change suggestion a while back try and catch the case where there was a missing blank in X =<<...>>.

Sorry for getting worked up about this but I wish people would think through their suggestions a bit more and consider the deeper implications of them.

Finally one definite reason not to outlaw a+42 is that it is one of my standard ways of generating an error in code, being much shorter to write than exit(some_bogus_exit_value). I also use 1=2 (N.B. only one =). Which should also be banned I suppose.

Robert

P.S. If things like this are added to the compiler then it is time for an alternate compiler.

----- Original Message ----- 
From: "Kostis Sagonas" <kostis@REDACTED>
To: <erlang-questions@REDACTED>
Sent: Wednesday, December 10, 2003 6:25 PM
Subject: Small poll


> I was wondering whether the Erlang user community would care
> to comment on the following:
> 
> In a function like:
> 
> test(A) ->
>     a + 42.
> 
> which is either crap (arguably) or a typo (A vs a), how many
> Erlang users:
> 
>  1. Are content with the current situation where the compiler
> happily compiles this program
>  2. Would like to see a warning, but a .beam file generated
> nevetheless
>  3. Would prefer if the compiler in R10 refused to compile it
> 
> Notice I am not talking about any serious attempt to static
> type checking, but for really "basic" checks.
> 
> Kostis.




More information about the erlang-questions mailing list