Original Post
Hi guys, I'm trying to decide what syntax I should use for function pointers in AngelScript. I would very much like some feedback from the community on this: So far I've come up with two alternatives, but feel free to suggest others. Alternative 1: C function pointer style: Alternative 2: C++ template style: Alternative 3: Inspired by C# delegates: Which alternative do you prefer? It would be great if you state the reasons for your opinion too, but it is not necessary. Thanks, Andreas [edit]Added alternative 3 based on xivVerge's suggestion about delegates[/edit] [Edited by - WitchLord on January 4, 2010 12:58:00 PM]
// A function pointer variable
void (@funcPtr)() = null;
// A function that takes and returns a function pointer
void (@)() retFuncPtr(void (@f)()) { return @f; }
// Typedef
typedef void (@functype)();
// A function pointer variable
function<void f()> @funcPtr = null;
// A function that takes and returns a function pointer
function<void f()> @retFuncPtr(function<void f()> @f) { return @f; }
// Typedef
typedef function<void f()> functype;
// Typedef - required in order to use the function pointer
typedef void functype();
// A function pointer variable
functype @funcPtr = null;
// A function that takes and returns a function pointer
functype @retFuncPtr(functype @f) { return @f; }