Small poll

Joe Armstrong joe@REDACTED
Tue Dec 16 11:58:58 CET 2003




> 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?
> 


Quite right.

As I pointed out before there can be two possible reasons why the
programmer wrote a+42.

	1) The programmer made an error, or,
	2) The programmer wants the system to raise an exception.

   THERE IS NO WAY THE COMPILER KNOWS WHICH OF THESES TWO CASES APPLIES

   (Sorry for shouting)

   Conclusion:

  You  must tell  the  compiler (ie  the  compiler needs  to know  the
programmer's intention - << what I call intentionality >>)

   There are two ways of telling the compiler:

	a) add pragmas to Erlang

	   pragma(bad_code) 
		a+42
	   end

	b) add a known wrapper that the compiler understands

	   for example make a function

	   this_is_not_an_error(X) -> X. and then call it thus:

	   this_is_not_an_error( a + 42)


   Method b) needs no syntactic changes to the language, and (I guess)
a very simple change to the compiler.

		
   If we adopt b) then the compiler should reasonably behave as follows:

	a+42                               Produces a warning 
					   and compiles the code correctly

	this_is_not_an_error(a+42)         Compiles the code correctly
					   with no warning

   In both cases the function is compiled - the only difference is 
whether you warn or not.

  Robert  is entirely  right -  legal  code must  ALWAYS be  correctly
compiled --- the compiler should  never try to outguess the programmer
and guess  that this  was an error  - half  our test suits  would stop
working if this were the case.

  /Joe










More information about the erlang-questions mailing list