[fpc-pascal] Named optional arguments

Michael Van Canneyt michael at freepascal.org
Fri Nov 26 09:31:20 CET 2021



On Fri, 26 Nov 2021, Ryan Joseph via fpc-pascal wrote:

> This was discussed before some years ago with no conclusion (https://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg46280.html) but I'd like to bring it up again. Can we consider extending the variant dispatch call named parameters to normal functions? The majority of the infrastructure is already there so it needs to merely be extended.
>
> This is what the syntax would look like:
>
>  SetupCanvas(width := 500,
>                         height := 500,
>                         eventCallback := @HandleCanvasEvents,
>                         options := [TCanvasOption.VSync]);
>
> The reason for this is of course to handle functions with many parameters so we don't need to look at the function definition to know which params mean what thing.

That seems like a fake argument: Of course you need to look, because you need the names ?
Secondly, the IDE will simply tell you what the names are when the cursor is
on them.

Michael.



More information about the fpc-pascal mailing list