[fpc-pascal] same routine with different parameters?

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Tue Oct 29 23:53:58 CET 2013


waldo kitty wrote:

>> Another
>> useful variant is giving *the* *last* parameter an optional value, 
>> which will
>> allow you to omit the parameter:
>>
>> procedure MyObject.MyRoutine(const VarA : string; VarB: integer= -1);
> 
> very interesting... will this work with both parameters, too? i don't 
> think i need it in this specific situation, though... i'm mainly wanting 
> to provide the original unmodified routine and my modification of it so 
> i can return something to that 3rd party library development...

Yes, provided that you don't also try to have a procedure with no 
parameters. In general, the compiler will tell you if you're doing 
something silly.

Assume that this is for value parameters only. In particular, I don't 
think there's a way of defaulting a var parameter to a nil pointer.


-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list