Delphi, methods and default values.
Being somewhat unique in methods declaration for the classes, Delphi requires you to have proper method parameters declaration, but:
- You do not have to have any default values for the parameters being propagated into implementation section for the method.
- And you do not have to have any parameters being specified in implementation section at all.
- If your class implements an interface, then while order and type of parameters remain unchanged for the interface method implemented, compiler would not not even detect it.
- When declaring the method and then using code complete feature of the IDE, stub generated would have all parameters but no default values.
- Declaration of the parameters could be “optimized” by changing the way they are grouped if they are of the same type. And sync is not enforced between declaration and implementation.
Convenient. Nice. Easy.
Again, it is convenient since it does not force you to propagate your changes between two if you are to change your default values.
Is default value good or evil?
Well, Microsoft saying it is specific to an implementation of the language (C#) and suggests to use overloads instead. Yes, it can be done, but defaults were introduced for a reason. And, in fact, some compilers, even Delphi, would be confused with overloaded declaration if there is a slight chance of mixing two.