I personally don't like these inline declarations. Why have them? They just goof up the readability of the routine. Now, if I look at the declaration of local variables, I don't know how many more might be defined later. So I don't have a good idea of the variable "context" before starting to read the logic (the code). I've used languages that allowed such things LONG ago when I used PL/I. And they didn't bother me then. After many years of Pascal, I now understand the benefits of declaration separate from code. I assume the main reason that someone would want the inline declaration is because it is too much of a bother to scroll back up to the declaration section to define it and then have to scroll back. Maybe it would be better if the editor just had a command that pushed the declarations back up to the top. On the other hand, again from PL/I, if the inline declaration has a different scope, that is something else again. So if a new, nested begin end block contained an inline variable declaration, I suppose I could understand its use. But I would rather see the editor pull such bits of code up to a local procedure. Again for readability. And if the inline variable and local block scope were being used to get some sort of performance advantage by not having to make a local call, I would rather see the optimizing compiler figure that out. Readability is what makes me stay with Pascal.
|