Delegate part

Delegate parts provide models for functions.
Delegate parts have the following characteristics:

Syntax

Syntax diagram for a Delegate part
delegatePartName
Specifies the name that you assign to the Delegate part.
parameters
A list of parameters that a matching function must have. The parameter types and modifiers that are defined for the delegate must be the same as those in the matching function. The parameter names might differ.
type
The type that a matching function must return.

Example

Here is an example of a Delegate part in the context of a program:
Delegate FunctionInvoker
  (displayStr STRING)
end

Program greetings
// declare delegate variable
invoker FunctionInvoker;

  Function main()
    // writeToScreen() must match Delegate parameters
    invoker = writeToScreen;

    invoker("Hello world");
  end

  Function writeToScreen(myMsg STRING)
    sysLib.WriteStdOut (myMsg);
  end
end

Compatibility

Table 1. Compatibility considerations for the Delegate part
Platform Issue
iSeries® The Delegate part is not available.

Feedback