Il 20/02/2019 19:11, Nikolai Zhubr ha scritto:

Now it is getting even more curious. Admittedly I don't use C too much (and C++ even less so, approximately never), maybe that is why I do not understand your reasoning. Could you maybe give an example of such problematic inline declaration and its negative effect, in C++ at least? Honestly I can't imagine any.

Very easy: you read your code written some time before, or someone else's code, you miss the inline declaration, because it's buried in the code, and you mistake the variable with another one previously declared, in the outer scope.

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

--
Do not do to others as you would have them do to you.They might have different 
tastes.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to