Hi,

09.03.2019 21:06, Anton Shepelev:
[...]
Pascal is a language where declaration and use of
variables is separated.  It makes it easy to see what
[...]
   a := a + Func1( b );
   int b := Func2( a );
   a := a - Func3( b );

Also worth reference are Bart's thoughts on the subject, in
two parts:

   http://al.howardknight.net/msgid.cgi?ID=155215407800
   http://al.howardknight.net/msgid.cgi?ID=155215418300

In short, if you let me, the all so lengthy and endless reasons boil down to approx these simple 3:

1. It might let people write ugly, horid, unreadable, unreliable code.
2. It might require you to scan some lines up to see the declaration.
3. Name clashes are possible (if implemented and/or used incorrectly).

And regarding all these: yes, as it is now, no much more, no much less.

No one would decide to declare "x", "y" in a declaration section and separately "z" somewhere deep in the body if "x, y, z" are actually coordinates of a point, unless s/he does that on a sole purpose of intentionally mocking colleagues and producing LOLs.

Its pretty odd to deny nowadays that block-local declarations do have their valid use and work just fine, if used reasonably. I'll certainly continue using them, where appropiate (in Java). Also I'll certainly continue using FPC because it is an absolutely brilliant and efficient product anyway with apparently no real-world alternative except just Java. On the other hand, Java's syntax is not as descriptive and has some ugliness in parts (and it hurts my eyes plenty). Therefore, my initial question was out of a (real-world motivated) curiosity regarding how (and why) declarations would ideally be better arranged so as to achive readability and reliability in various cases, considering both C's approach, Java's approach and maybe Embarcadero's approach, however as just a reference, not a requirement for immediate implementation "just because they all have it". So far I've only got the abovementioned cases 1-3 which are in fact irrelevant. Plus a general "declaration and use is separated" mantra which I fail to find sufficiently enlightening either. Well, ok. It is not a showstopper. At least not until a typical function gets 10000 lines long (which I try to resist :) ).


Thank you,

Regards,
Nikolai


Please, do not turn Pascal into another C# or Java.


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

Reply via email to