Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 246651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:11:25+00:00 2026-05-11T21:11:25+00:00

In one of the Delphi demo applications, I’ve stumbled upon some syntax that I

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:11:26+00:00Added an answer on May 11, 2026 at 9:11 pm

    Clearly the Delphi language supports named parameters since they appear right there in sample Delphi code. Delphi supports named parameters on automation objects, which are objects that implement the IDispatch interface. There are restrictions on the types the parameters and return types can have; in particular, they can’t be Delphi classes.

    I don’t think the convenience you seek from named parameters would outweigh the performance hit you’d take by having every method call routed through the IDispatch.Invoke method. A call may also need to use GetIDsOfNames first. You don’t see this in more code because late binding is usually something people try to avoid. Use early binding whenever possible to avoid the cost of looking up dispatch IDs and indirect method invocations.

    Delphi supports optional parameters in non-automation code by allowing default values. You can omit the actual parameters for any parameter with a default value as long as you also omit the actual parameters of all subsequent parameters — the compiler ensures that a function’s declaration allows for that.

    I think optional parameters are overrated. They save time for the (one) person writing the code, but not for the (many) people reading the code. Whoever’s reading it needs to know what the default values will be of any unspecified parameters, so you may as well just provide all the values explicitly anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Delphi has a $WARN compiler directive that allows one to selectively enable or disable
I know someone who has a one-man company developing applications in Delphi and Pascal.
I copied some Delphi code from one project to another, and found that it
Delphi XE2, so I guess that is Indy 10(?). One server, 10 clients. I
I am trying to refactor some delphi 7 code. One of the procedures I'd
i'm writing a delphi app that communicates with excel. one thing i noticed is
Whenever I open one of the Quantum Grid demos in Delphi XE Pro (on
I have written an application in Delphi 2010 that imports data from one database
In a Delphi 7 project we installed FastMM. Soon after that we noticed one
One of Delphi 2009's advertised features was PNG support. That's great, because the Unicode

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.