[fpc-pascal] same routine with different parameters?

waldo kitty wkitty42 at windstream.net
Tue Oct 29 20:40:14 CET 2013

On 10/29/2013 2:35 PM, Mark Morgan Lloyd wrote:
> waldo kitty wrote:
>> example:  procedure MyObject.MyRoutine;
>>           procedure MyObject.MyRoutine(VarA : SomeType);
>>           procedure MyObject.MyRoutine(VarA : string; VarB: integer);
>> at one point, the first instance would be used... at another point one of the
>> other instances would be used with the only difference being the parameters
>> that are passed or not... i know that i would have individual instances with
>> the necessary header and code for each... i just don't know if there is
>> anything else special that needs to be done or if it can be done with an
>> internal class object routine..
> Just give it a whirl as you've shown, I think you've got it right.

really? that easily?! no way! i was just guessing based on what i've seen in 
some of the documentation of some routines but i never guessed that it would be 
that easy to do at any time :)

> 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...

FWIW: i decided to try this because i was unable to (hope i'm using the proper 
terms here) derive a new object from the existing one and override this one 
inherited routine with my modifications... this would allow me to add my own 
variables to the object in addition to what it comes with and allow me to have 
this routine as i need it... but that didn't work for some reason and i've 
already ripped out all that attempt and gone this route with my modified routine 
and direct addition of the variable... i just want to be able to provide 
something back with as little intrusion to the original as possible...

NOTE: No off-list assistance is given without prior approval.
       Please keep mailing list traffic on the list unless
       private contact is specifically requested and granted.

More information about the fpc-pascal mailing list