I have started Pascal programming with problems on SPOJ a few months ago. So the first thing that comes to mind is performance.
I am learning.
Thanks.
BTW
Quote is from Marco Cantù "Object Pascal Handbook".
I never use Low, High on dynamic arrays. May be it's my mistake. Who knows? Enlighten me, please.
You're welcome. I suggest you take performance a few notches down the totem pole.
The best performance is derived from selecting good algorithms. That's what being a good programmer is about, having a large bank of algorithms in your head and selecting the one that best fits the problem at hand.
Optimizing code is the compiler's job, not the programmer's. It seems not very many programmers realize that.
I suggest you read these two books:
1. Algorithms by Robert Sedgewick. The second edition - which you can get quite cheap - presents the algorithms in Pascal pseudocode. Later editions are C "flavored".
2. Brinch Hansen On Pascal compilers. Teaches you how to write a compiler but, if you really pay attention, you'll find that it is a lot more than about writing compilers. IMO, there is no book that comes even close to teaching as much about programming than that book does. Unfortunately, it is a bit pricey even used but, it's worth its weight in gold (if you read it attentively, that is.)
After those, select books written by people who have a solid background in computer science. John Bentley's books "programming pearls" are excellent reads too. To learn Pascal, I always recommend "oh Pascal" from Doug Cooper, an excellent book, superb programming advice.
As far as the use of "low" and "high". The thing to always keep in mind is, does the compiler offer something that would prevent a mistake ?. When the answer is yes then use that even if it costs a few extra clock cycles, you got roughly 3 billion of them per second, a few clock cycles here and there will not make any humanly perceptible difference but, they'll make a big difference when you forgot to subtract 1 because you didn't want to spend them.
Best advice I can give any programmer: put performance after maintainability and ease of understanding the code. You'll appreciate it when you look at your own code again, a year later and, it isn't full of "tricks" to save a cheap processor the burden of spending a few clock cycles to make your life easier. Make that CPU for you, don't work for the CPU.
Lastly, spend your time commenting your code. What is obvious to you when you're writing the program is unlikely to be obvious a year or two later when you're trying to add a feature or fix a bug. You'll appreciate having spent the time commenting what seemed obvious then.
@SergeYes, it is interesting that it doesn't inline High.