[fpc-devel] Does FreePascal support named parameters?

Anthony Walter sysrpl at gmail.com
Tue Apr 2 05:37:27 CEST 2013


Name parameters are supported through variants.

procedure Test(V: Variant);
begin
  V.SomeMethod(12, ParamOne := '', ParamTwo := 12.5);
end;

Internally what happens is V is checked to for IDispatch, next
GetIDsOfNames is called to find the dispid of SomeMethod, then a variant
array of arguments is constructed (with the names), and finally Invoke is
called.

This comes from the Microsoft COM concept of "automation",
though automation encompasses a bit more than IDispatch, including
marshalling, remoting, and error handling; passing errors back from a
remote machine for example.

People don't really use this stuff much anyone, nor is their much demand
for people with knowledge of the inner workings of COM. But if you want,
you can write your own objects which implement IDispatch.

See the source code in the download link on this page:
http://www.codebot.org/delphi/?doc=9573

ScripTools.pas class TScriptlet which exposes arbitrary pascal methods and
properties to a Javascript engine.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130401/e64fdf66/attachment.html>


More information about the fpc-devel mailing list