diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-19 10:20:11 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-19 10:20:11 +0200 |
| commit | 03b874818315e7dc9fb2ccf26716a0fb65242a57 (patch) | |
| tree | cc375998c809ded77d920f6a2a2a50241018f016 /examples/func_args_ret.fy | |
| parent | 2e81f599a0323e2025883bc1375bf438d1406733 (diff) | |
Rename func keyword to fun
Replace the `func` language keyword with `fun` throughout: update the
scanner's string-to-token mapping, all .fy example scripts, and all
documentation files (.txt, .pod, .tex, .man, .html).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'examples/func_args_ret.fy')
| -rw-r--r-- | examples/func_args_ret.fy | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/func_args_ret.fy b/examples/func_args_ret.fy index 54088e8..2039501 100644 --- a/examples/func_args_ret.fy +++ b/examples/func_args_ret.fy @@ -1,13 +1,13 @@ # Test: function named arguments, explicit ret, and multiple return values # zero-arg function with explicit return -func answer() { +fun answer() { ret 42; } assert 42 == say answer(); # single-arg function — factorial with a while loop and ret -func factorial(n) { +fun factorial(n) { my result = 1; while n > 1 { result = result * n; @@ -18,13 +18,13 @@ func factorial(n) { assert 120 == say factorial(5); # two-arg function -func add(a, b) { +fun add(a, b) { ret a + b; } assert 8 == say add(3, 5); # conditional return inside if -func absval(n) { +fun absval(n) { if n < 0 { ret neg n; } ret n; } @@ -32,14 +32,14 @@ assert 5 == say absval(5); assert 5 == say absval(neg 5); # multiple return values — both land on the caller's stack -func minmax(a, b) { +fun minmax(a, b) { if a < b { ret a, b; } ret b, a; } say minmax(3, 7); # old-style zero-arg function without parens still works -func greet { +fun greet { say "hello"; } greet; |
