[erlang-questions] Erlang/YAWS vs Free Pascal/Xitami

Jilani Khaldi jilani@REDACTED
Thu Mar 27 11:05:25 CET 2008


 > Most dynamically typed or "scripting" languages will catch most instances
 > of identifier typos before run-time. There are some (not Erlang), 
that get
 > it egregiously wrong, though: in Javascript/ECMAScript, for instance, 
a typo
 > in a variable name will typically either cause a silently incorrect 
creation
 > of a global variable (if on the LHS of an assignment), or result in a
 > silently incorrect 'undefined' value.
I meant both.
Example (1) from a true code in Lua (http://www.lua.org) to extend an 
application at run-time:
...
-- All variables are declarated static
   coefSch=(Mr-Ms)/(G+S*sin(delta*pi/180))
   if delta == 0 then
(*)    coefScor=tan(0.666*fi*pi/180)*G/(S+deltaF+FF)
   else
     Temp1=tan(delta*pi/180)
     Temp2=G+S*sin(delta*pi/180)+deltaF*sin(delta*pi/180)
     Temp3=S*cos(delta*pi/180)+deltaF*cos(delta*pi/180)+FF
     coefScor=Temp1*Temp2/Temp3
   end
At the line (*) I wrote  "coefScorr" instead of "coefScor" and Lua 
compiler has considered "coefScorr" as a *new global variable* (Ruby did 
the same thing) and the code runs 'fine'! This kind of errors are very 
subdle and frequent.

Example (2) in Pascal:
var
   x, y: longint;
   zz: integer;
begin
   x := 12345678988;
   y := 34567899999;
   zz := trunc(x+y);
   writeln(zz);
end.

FPC puts out:
8 / 8 exp.pas
  Warning: range check error while evaluating constants

And writing this:
var
   x, y: longint;
   zz: integer;
begin
   x := 12345678988;
   y := 34567899999;
   zzz := trunc(x+y);
   writeln(zz);
end.
10 / 6 exp.pas
  Error: Identifier not found "zzz"
11 / 3 exp.pas
  Warning: Variable "zz" does not seem to be initialized
You need this kind of checking when you write technical software used in 
real life
Now, it is true I have to write a lot of code in Pascal and much more in 
Ada, but at the end, at least in my case, I have really saved my time, 
my eyes and my health.

-- 
***
Jilani KHALDI
http://www.dotpas.org



More information about the erlang-questions mailing list