[fpc-pascal] named parameter

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Mon May 29 10:56:45 CEST 2017


On 29/05/17 05:15, Ryan Joseph wrote:
>> On May 28, 2017, at 5:22 PM, Mark Morgan Lloyd <markMLl.fpc-pascal at telemetry.co.uk> wrote:> >> IMO though it does improve readability in long functions with lots of>> parameters, like windows api style procedures that have 5 or more>> parameters and you can't figure out which param is>> which>
> You mean like this?
> function Foo (theString: string; options: set of TFoo): boolean;beginend;
> Foo(theString: 'foo', options: []);
> Objective-C has this mandatory and it made for stupidly long method names that just looked terrible but it was optional Pascal makes it look nicer. The declaration syntax is already the same as the label for the calling syntax so that seems like a nice fit.

Except that there's no provision for setting a parameter passed as a set 
element to true if it's not given explicitly. Sometimes you want that, 
and simply inverting the meaning of a parameter results in values which 
appear contrived in the context of the "real world" problem being solved.

The example I gave was from a terminal emulator, where "echo", 
"loopback" and so on are well-accepted concepts in the industry. And 
having a parameter "any_character_set_as_long_as_its_not_apl" is 
downright silly :-)

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