Previous: , Up: Well-formedness – Functions   [Contents][Index]


11.10.3 Cannot use statement after recursive call

A function that is recursive must be tail recursive, i.e., in its body any recursive function call shall not be followed by other statements. So:

interface function_not_tail_recursive
{
  in void hello ();
  behavior
  {
    void f ()
    {
      bool b = false;
      if (b)
      {
        f ();
        b = true;
      }
    }
    on hello: f ();
  }
}

This results in the following error message:

function-not-tail-recursive.dzn:11:9: error: cannot use statement after
    recursive call
function-not-tail-recursive.dzn:12:9: info: statement after call

Note: Two functions f and g that are defined in terms of each other are mutual recursive and are thus also considered to be recursive.