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 --- doc/DESIGN.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'doc/DESIGN.md') diff --git a/doc/DESIGN.md b/doc/DESIGN.md index fae9ef2..f9e3cef 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -13,7 +13,9 @@ const main = fn { ``` const main = fn { var value = 23 + 50; - if value < 23 + if value == 0 + stderr.writeln("zero!"); + else if value < 23 stderr.writeln("less!"); else stderr.writeln("more!"); @@ -28,20 +30,14 @@ const main = fn { ## Closure Parentheses after `fn` is only required when the closure has parameters or returns data ``` -const apply = fn(func: () bool) { +const apply = fn(func: fn() bool) { const result = func(); } const main = fn { - // Return type is automatically deduced. If function returns multiple different types at different points, - // then you get an error and are required to specify the return type - apply(fn { - return true; - }) - apply(fn() bool { return true; - }) + }); // Or store in a variable and use it const func = fn { -- cgit v1.2.3