Small poll
Kostis Sagonas
kostis@REDACTED
Wed Dec 17 01:36:10 CET 2003
Robert Virding wrote a mail quoting my mail, and he finished it as
follows:
> ... deleted ...
>
> 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 will try to avoid the temptation of replying directly to the first
statement above, and instead reply to the following question of Robert.
> 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.
Ah, Robert, you seem to have very limited imagination... let me help
you here. Consider the code:
-module(a42).
-export([test/0]).
test() ->
catch f(),
ok.
f() when a+42 == 0 ->
%% extremely long sequence of code here
ok_1;
f() ->
Y = ackerman(), % very long computation here
% (without side-effects)
X = a+42,
mod:funct(X,Y),
%% possibly lots more other code here
ok_2.
ackerman() -> ....
QUESTION 1
----------
Do the "semantics" of Erlang (BTW, I would really like to see them
formally specified before people use this term again) allow a compiler
to transform the code above to just:
-module(a42).
-export([test/0]).
test() ->
ok.
QUESTION 2
----------
Can the savings in time and code space be made arbitrarily big, or not?
QUESTIONS 3-N
-------------
- Do the two occurrences of "a+42" need to be treated differently
by the compiler in the above example, or not?
- Is "a+42" an expression that always generates an error in Erlang?
(as far as the user is concerned)
- Is it just me that finds this Erlang-ism confusing to say
the least? (I.e., is this a user-friendly language design?)
Kostis.
PS. I am very well aware that the subject has shifted from
warnings vs. errors to something else now, but I could
not resist. Apologies.
More information about the erlang-questions
mailing list