Use recursions mainly for processing recursive data types such as linked lists. Generally, we recommend that you be careful when using recursion. An unexpectedly deep recursion can lead to stack overflow and therefore to machine downtime.
Within their implementation, a method can call itself:
-
Directly by means of the
THIS
pointer -
Indirectly by means of a local function block instance of the basic function block
Usually, a compiler warning is issued for such a recursive call. If the method is
provided with the pragma {attribute 'estimated-stack-usage' := '<estimated stack size in bytes>'}
, then the compiler warning is suppressed. For an implementation example, see the
⮫ 'estimated-stack-usage' Attribute chapter.
-
See also: ⮫ THIS