[fpc-pascal] named parameter

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sat May 27 12:13:21 CEST 2017


On 27/05/17 09:40, Ryan Joseph wrote:
>> On May 27, 2017, at 4:27 PM, Graeme Geldenhuys <mailinglists at geldenhuys.co.uk> wrote:> > Yeah, that was going to be my suggestion too. I've done this many times when many parameters are optional. Use a record as parameter type. The other benefit of this is that it is future and backwards compatible. You can add or change parameters without breaking the method signature.
> can you show an example of this? Just curious.

IIRC the problem is that while it's possible to initialise a record 
constant by named fields processed in arbitrary order, the compiler at 
present doesn't allow it to be done inline:

someFunction(TPoint(X:0.0; Y:0.0));

Pascal purists would probably object to that style, since what it's 
effectively doing is passing the parameters as an explicit list.

Somebody please correct me it I'm wrong.

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