1. Computing

Understanding Anonymous Methods in Delphi

By March 20, 2012

Follow me on:

in Delphi Language :: In short, an anonymous method is a procedure or function that does not have a name associated with it. Anonymous methods extend existing procedural types and by allowing you use the actual code of a method as a parameter to some other method. In addition, an anonymous method can refer to variables and bind values to the variables in the context in which the method is defined.

Read the full article to learn how to Write Less Code For More Power


October 4, 2010 at 11:59 pm
(1) Dorin Duminica says:

I would NOT recommend the use of anonymous method(s), first because the code is less readable and second I can see a lot of problems while debugging code with anonymous method(s).
In short if you DO use them, try to keep them as short as possible ~ 5-10 lines max…

March 20, 2012 at 9:44 am
(2) Yanniel says:

I do think that anonymous methods are useful; but as everything in life, you have to know when to apply them. Here’s another article about anonymous methods in Delphi.

March 20, 2012 at 3:27 pm
(3) Don Rowlett says:

Pascal has had procedural types for a long time. A type is defined as a procedure or function. A variable is defined as this type before assigning a procedure (or function) to this variable. From the examples I only see a syntactic difference between this older strategy and the newer “anonymous methods”. Maybe the examples I looked at are too simple. Is there an advantage using anonymous methods over procedural types?

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.