This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Custom support for function pointers.

Just as the compiler has added custom support for bits, it should also add custom support for function pointers.

Here is one idea:

//Saves on storage (1 byte)
//Is faster (fixed jump table)
//No need to add/remove references in the linker

void fn1( void ){};
void fn2( void ){};
void fn3( void ){};
void fn4( void ){};

enumfn MyFnType { fn1, fn2, fn3 }; //must have same signatures

MyFnType myFnVar;

void FnA(void)
{
  myFnVar = fn1;  // do not add fn1 to FnA's call tree
  myFnVar = fn4;  // compiler error
}

void FnB(void)
{
  (myFnVar)();   // do add fn1,fn2,fn3 to FnB's call tree
}