3 ms·
Delphi allows inline variable declaration but Free Pascal does not (the developers explicitly decided against implementing it). Note that in Pascal (FPC, Delph
by badsectoracula 3y ago
Delphi allows inline variable declaration but Free Pascal does not (the developers explicitly decided against implementing it).
Note that in Pascal (FPC, Delphi, whatever) you can have nested functions so this isn't that much of a limitation as it sounds. For example if i have a procedure that is very long i often end up splitting it in multiple nested procedures and each one has its own variable section.
Also from a more practical perspective Lazarus (the most common FPC IDE) has a shortcut key to automatically insert variable declarations so you don't have to move up and down in code even if you have a large function body. I'd expect Delphi to have something similar.
- zabzonk 3y ago> Delphi allows inline variable declaration it may do so now, but for the longest time it didn't, which made it compare poorly with C++ and even with C, which allows definitions in a scope. in fact the OP concept of scope is a bit crap - basically the whole function,
- pjmlp 3y agoYour concept of Object Pascal scope is also outdated, in relation to Delphi.