Is it correct to put a procedure declaration before implementation sectionyes.
.. and why is it acceptable to ignore procedure declaration and just work with its copy that's within implementation section?It just "private" function to unit implementation.
Is it correct to put a procedure declaration before implementation section and why is it acceptable to ignore procedure declaration and just work with its copy that's within implementation section?
.... or if you need a forward-declaration (for whatever reason) within the same unit?Is it correct to put a procedure declaration before implementation section and why is it acceptable to ignore procedure declaration and just work with its copy that's within implementation section?
You only need to declare a function or procedure in the interface-section (which is the section before the implementation-section) if you want the routine to be accessible from another unit.
.... or if you need a forward-declaration (for whatever reason) within the same unit?
I think I'd argue that you shouldn't put something in the interface section unless you really need to export it, in the same way that you shouldn't put something in the public section of a class unless you are prepared to take the consequences of its being called under conditions you didn't anticipate.While generally good advice, this only works until you start using generics:
It's good mentioning for "generic paradigm", I would ask if free pascal supporting this style of programming.
It's good mentioning for "generic paradigm", I would ask if free pascal supporting this style of programming.
Why would he have given you an example if it didn't?
MarkMLl
.... or if you need a forward-declaration (for whatever reason) within the same unit?Is it correct to put a procedure declaration before implementation section and why is it acceptable to ignore procedure declaration and just work with its copy that's within implementation section?
You only need to declare a function or procedure in the interface-section (which is the section before the implementation-section) if you want the routine to be accessible from another unit.
If you specialize in the interface section, the implementation part works OK.
Of course you can, Sarah:
unit naamloosunit; {$mode delphi} interface type TspecializeMe = TArray<Integer>; // specialized implementation end.
You can't specialize a generic ROUTINE in the interface-section.