Show/Hide Toolbars



Declare a delegate to  the compiler.


 [Attributes] [Modifiers] DELEGATE <idDelegate>


 [([<idParam> [AS | REF|OUT|IN <idType>] [, ...])]

 [AS <idType>]



AttributesAn optional list of one or more attributes that describe meta information for am entity, such as for example the [TestMethod] attribute on a method/function containing tests in a MsTest class library. Please note that Attributes must be on the same line or suffixed with a semi colon when they are written on the line above that keyword.


ModifiersAn optional list of modifiers that specify the visibility or scope of the entity, such as PUBLIC, PROTECTED, HIDDEN, INTERNAL, SEALED, ABSTRACT or STATIC.


<idDelegate>A valid identifier name for the delegate.  Delegate names must be unique within a namespace.


<idParam>A  parameter variable.  A variable specified in this manner is automatically declared local.  These variables, also called formal parameters, are used to receive arguments that you pass when you call the entity.


AS | REF|OUT|IN <idType>Specifies the data type of the parameter variable (called strong typing).  AS indicates that the parameter must be passed by value, and REF indicates that it must be passed by reference with the @ operator. OUT is a special kind of REF parameter that does not have to be assigned before the call and must be assigned inside the body of the entity. IN parameters are passed as READONLY references.
The last parameter in the list can also be declared as PARAMS <idType>[] which will tell the compiler that the function/method may receive zero or more optional parameters.
Functions or Methods of the CLIPPER calling convention are compiled to a function with a single parameter that this declared as Args PARAMS USUAL[]


AS <idType>Specifies the data type.  If omitted, then depending on the compiler options the type will be either USUAL or determined by the compiler.


TypeParameterConstraintsHere you can specify constraints for the Type parameters, such as WHERE T IS SomeName or WHERE T IS New



A delegate is a reference type that encapsulates a function or method. Delegates are similar to function pointers in native code languages such as Visual Objects, C and C++, but unlike function pointers, delegates are object-oriented, secure and type-safe.

The DELEGATE statement declares a special type of class which is partially implemented by the compiler, and partially implemented by the CLR. All delegates inherit from System.MulticastDelegate.

Every delegate has a signature, which is a combination of its parameter and return value types.


You can explicitly call the delegate constructor like:

f := MyDelegate{ NULL, @SomeClass.Test() }

for static methods :

f := MyDelegate{ SELF, @SomeClass.Test() }


for instance methods, it is also possible to write:

f := SomeClass.Test

for static methods:

f := SELF:Test