Am 01.04.2013 20:29 schrieb "Frank Church" <vfcli...@gmail.com>:
>
> Does FreePascal support named parameters?
>
> Are they in the pipeline?

Yes and no. As Anthony wrote such a construct is available for Variants and
thus is supported by the parser. Normally this is disabled though. In case
of the parser you should look out for "named_args_allowed" (or similar).
What I don't know though is how the names parameters are handled after
that...

>
> Func(aNumber: integer; aString: string);
>
> I want to be able to write Func(aNumber := 4, aString := 'anystring');
> If I type Func(aString := 'anystring',4) the compiler should generate
> an error as the order of parameters has been changed.

As said: this syntax is already supported (though I don't know to what
extent your example would work).

> Coming to think of it will be just as easy to wrap the parameter names
> in comments i.e Func({aNumber}4, {aString} 'anystring'), much simpler
> and almost is good. Is such a style acceptable? I don't mind using it
> in my own code.

And here we can see that you haven't worked much with the internals of the
compiler yet (Note: no offence intended). Using comments for anything
besides comments (and compiler directives) is extremely hard, because they
are entirely handled by the scanner. The parser will not know that a
comment existed there.

Regards,
Sven
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to