Was: String parameters in Delphi

I think we all connected… “We are Borg. You will be assimilated. Resistance is futile”… weird…

Do you know a rest of it? “But we’re not at home right now, so leave a message after the tone and we’ll assimilate you later… (beep)” 😉 (link)

Ok, lets come back to the strings… 2 weeks ago Chris Bensen (CodeGear’s Sr. R&D engineer) wrote in his blog about STRING type being passed as parameter and what are associated “costs” for your application. Very good thing to read along with discussion. Of course many have known about this at some point while working with Delphi, but value of the post that it brings it all together and shows why it happens.

More to it for know source (Delphi help):

Constant Parameters (Delphi 2006)
A constant (const) parameter is like a local constant or read-only variable. Constant parameters are similar to value parameters, except that you can’t assign a value to a constant parameter within the body of a procedure or function, nor can you pass one as a var parameter to another routine. (But when you pass an object reference as a constant parameter, you can still modify the object’s properties.) Using const allows the compiler to optimize code for structured – and string-type parameters. It also provides a safeguard against unintentionally passing a parameter by reference to another routine.

Reading classics:

PS. I think  if you are on this level of optimization, then there is probably something wrong with the design of your app itself. “What-not-to-do” or “How-to-do-things-in-the-right-way” should be in your style of programming and not a magic wand to squeeze a few milliseconds out of your application…

Enjoy results of your findings.

This entry was posted in Delphi. Bookmark the permalink.

Leave a Reply

  • About

    From a junior developer through Sr Manager position, I was always interested in new technologies. Passionate speaker, IT junky, developer, architect, team lead, and development manager - many hats, one goal - making software better and being closer to people’s needs. For the most part I am using my blog as a scratch pad, writing small articles on things which I came across, was asked about more then once, and which would otherwise require additional research again and again.

    View Serguei Dosyukov's profile on LinkedIn
  • Testimonials

    I've been using this [theme] since the start. It is by far the most attractive, feature packed and stable of...


    The greydragon theme is fantastic. It’s clean, stable and feature rich. It took me a while to decide to move...


    I’m a huge fan of this theme. I’ve got more than 90,000 pictures in my gallery3 running on a Ubuntu...



  • Categories