[fpc-devel] "Blank slate" next version of FPC

Nikolai Zhubr n-a-zhubr at yandex.ru
Wed Feb 20 20:47:15 CET 2019


Hi,
20.02.2019 21:28, Giuliano Colla:
[...]
> I have just met such a situation: I ported from C++ to Pascal an
> algorithm for the computation of the kinematics of a Delta Robot, and I
> was badly bitten.
> In that case you are just dealing with X,Y,Z coordinates, and
> Theta0,Theta1,and Theta2 angles, and you find, in the body of a
> procedure, some X,Y,Z or Theta which have global scope, and some which
> are just local to some smaller (but not too small) block and which are
> redeclared inline. Rather hard to tell them apart.

Excellent! Such redeclarations should obviously be borbidden. Otherwise 
it would loose almost the whole point. Java certainly rejects them.
And, it is easy to identify and reject such name clashes in this case, 
because the offending statement (declaration) can clearly be located.

On the other hand, I've been biten plenty by the already existing name 
clashes like:

   with Button1 do
   begin
     Left := ClientWidth div 2;
     .....

and here nothing can probably be done to help at compiler part, because 
the statement is perfectly valid despite so obviously erroneous. I've 
seen some people even prepending "self." to almost any identifier in a 
desperate attempt to eliminate ambiguities. (And yes, it looked 
disgusting enough)


Thank you,

Regards,
Nikolai

> Redeclaring inline an index I, which you'll be then using a lot of
> times, is the best way to shoot you in the feet. Pascal encourages you
> to use I,J,K at first, then ii,jj,kk etc.
>
> Moreover, using a modern tool such as Lazarus, you never need to scroll
> 1000 lines to find a declaration: you just press alt+Up to go to the
> declaration of the symbol over the cursor, and Ctrl+H to go back to the
> line of code.
>
> Keeping all declarations separated from code is just good programming
> practice. Mixing declaration and code is bad programming practice, IMO,
> and I appreciate Pascal for not supporting it.
>
> Giuliano
>




More information about the fpc-devel mailing list