Wed Dec 10 22:02:16 CET 2003
On Wed, 10 Dec 2003, Kostis Sagonas wrote:
> 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
> 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.
I would choose 2, which btw is the behaviour you get in this case if you
have set ERL_COMPILER_OPTIONS="[warn_unused_vars]". In the case where you
don't get that warning (for instance by using the variable earlier in the
function) I still like option 2.
It would be easy (and nice) to add a warning at all points where constant
propagation detects a possible (probable?) run-time error. I use the word
possible since I would like the warning in the case
case B of
true -> a + 42;
_ -> A.
The above function is also a good example of why option 3 is bad. There
might actually be a reason that the programmer wants to generate a
run-time error in the case that B is true (I can't think of one, but...).
Anyway it would be bad to disallow program lines that might actually never
even be reached.
btw Since I am delurking I should probably say hi to the list. Hi list.
I am a last year student at Uppsala University, studying Computer Science
and Mathematics (in no particular order of preference). I recently took a
course in compiler techniques where we rewrote the constant propagation
pass on the ICode level for HiPE. This made me interested in Erlang so I
started lurking here.
My email log says that I have been lurking since July, but in reality I
have been deleting more than I have read; increasing my read/delete ratio
steadily. Up to almost 1 the last week (or "division by zero exception"
depending on how you count).
Daniel Luna | Top reasons that I have a beard:
luna@REDACTED | a) Laziness.
http://www.update.uu.se/~luna/ | b) I can.
Don't look at my homepage (it stinks).| c) I can get away with it.
More information about the erlang-questions