From 902a81528b9d2edcf93226a2ca13da6fcc1839e5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 23 Dec 2019 08:57:48 +0100 Subject: wip: function pointers and other stuff --- tests/closure.amal | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/closure.amal (limited to 'tests/closure.amal') diff --git a/tests/closure.amal b/tests/closure.amal new file mode 100644 index 0000000..c5b3e15 --- /dev/null +++ b/tests/closure.amal @@ -0,0 +1,37 @@ +// extern const printf: fn(fmt: &c_char, ...) c_int; + +/* +const apply = fn(func: fn() bool) i32 { + //const f = func; + const result = func(); + //const result2 = f(); +} + +const main = fn { + // TODO: Test this + // const f = printf; + // f("hello"); + + apply(fn() bool { + return true; + }); + + // Or store in a variable and use it + const func = fn() bool { + return true; + } + apply(func); +} +*/ + +const f = fn(func: fn() i32) i32 { + func(); +} + +const bla = fn() i32 { + +} + +const main = fn { + f(bla); +} \ No newline at end of file -- cgit v1.2.3