Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Function Pointers

1 replies · 1,275 views · Started 25 December 2016

So, I've been making some progress to adding function pointers to zscript: https://github.com/gwx/ZeldaClassic/tree/function-pointers

[C]void test() {
Trace(-99);
}
void test(int x) {
Trace(x);
}
global script Active {
void run() {
int f = @test;
f();
f = @test(int);
f(-50);
}
}[/C]

Up until now, I've been focusing on getting it to work (which it does), but not any aspects of type safety.
So, continuing forward, I figure I can either add vaguely C style types:

int(bool, int) x = @test;

Or model it after angelscript's approach:

funcdef int TYPE_NAME(bool, int);
// ...
TYPE_NAME x = @test;

Any preferences on which, or other considerations?

(( Applauds ))

Fantastic work, mate. With you on the parser, while I wok on ZScript, we'll get this beastie done.