CTRL++ - Limitations

The following limitations apply to CTRL++:

  • Currently, the variable function_ptr does not accept functions, but only static member functions of classes.
    SimpleFunction() {}
    main() 
    {
      function_ptr p = SimpleFunction; //error
    }
  • In the code of a class member function, a member function_ptr cannot be called without "this". The use of p() alone is not yet implemented. You can use callFunction(p) instead.

    class Test 
    {
    
      public function_ptr p;
      public MemberFunction(function_ptr externalPtr) 
      {
        p = externalPtr;
        p(); // error
      }
    };
  • Global variables are invisible in the function code of the class members.
    global const int gc = 1;
    
    class Test 
    {
      MemberFunction() 
      {
        int i = gc; //error
      }
    };
    Anmerkung: Note that the global keyword only makes sense in libraries.
  • Currently, class members are read-only outside the code of class function members, except when assigned directly.
    class Test 
    {
      public int i;
      MemberFunction() 
      {
        i++;
      }
    };
    
    main() 
    {
    
      Test t;
      t.i++; //error
      t.MemberFunction(); // ok, changes member variables
    }
  • If an attempt is made to use enum objects as keys, the standard use does not work.
    Enum e 
    {
      first = 1
    };
    
    main() 
    {
      dyn_int array;
      dynAppend(array, 1);
      int i = array[e::first]; //does not work
    }
    The warning is shown: Default branch called, UIntegerVar, operator=, cannot assign variable of type CLASS_VAR
    i = e::first; // i == 0, warnings (see below)
    i = (int)e::first; // ok, not user-friendly
    The log looks like this and shows the location:
    WCCOActrl (0), 2017.03.08 17:41:16.949, CTRL, WARNING, 5/ctrl, Location of the following log entry: A Line: 32
    WCCOActrl (0), 2017.03.08 17:41:16.949, IMPL, WARNING, 50, Default branch called, UIntegerVar, operator=, cannot assign Variable of type CLASS_VAR
    
    By definition, an enum in CTRL++ is a typed enum, so you cannot assign it to an int without an explicit cast.
    It is better to define the target variable so that it has the same type. In this case use:
    e i = e::first; // no int, but e