In one of the Delphi demo applications, I've stumbled upon some syntax that I didn't know the Delphi compiler accepted:
// ......\Demos\DelphiWin32\VCLWin32\ActiveX\OleAuto\SrvComp\Word\
// Main.pas, line 109
Docs.Add(NewTemplate := True); // note the assignment
I can't seem to reproduce this type of parameter passing in my own code, and I never see anyone use it. So these are my questions:
Can i use this in "normal" methods and is it part of "the Delphi Language", or is this some compiler hack for automation objects?
What's needed in order to be able to use this?
Is this anything like C#4's named and optional parameters?
Additional information: I usually pass records or simple classes when there are many optional parameters to methods, but it looks like I wouldn't need that with this syntax. I'm aware of default parameter values, but their usefulness is limited because you cannot provide any parameters to the right of an omitted one. In JavaScript I'm using this named parameter style all the time (be it with different syntax), and it's powerful.