diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-12-23 08:57:48 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:37:00 +0200 |
commit | 902a81528b9d2edcf93226a2ca13da6fcc1839e5 (patch) | |
tree | ea868fae662aab61f1caa50b16a8b02fe1e6836b /doc/DESIGN.md | |
parent | 111bd0c7cb4b446c4bfe192b1df82845de17c005 (diff) |
wip: function pointers and other stuff
Diffstat (limited to 'doc/DESIGN.md')
-rw-r--r-- | doc/DESIGN.md | 14 |
1 files changed, 5 insertions, 9 deletions
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 { |