diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-11 13:50:01 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-11 13:52:46 -0500 |
| commit | 7f8f2117799cdfa6b62909a9182b5adade1d0bd2 (patch) | |
| tree | 1db466db870768e952f50572453660e090e434e0 /docs/functions.md | |
| parent | 630f910563b6f27dd34a4a0496a43d32539eadcb (diff) | |
| parent | 02886fab651d3f64d2c8ded5597e6c075dc69b5f (diff) | |
Merge branch 'dev' into constructive-reals
Diffstat (limited to 'docs/functions.md')
| -rw-r--r-- | docs/functions.md | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/docs/functions.md b/docs/functions.md index b325ee9a..11e1ea63 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -27,11 +27,9 @@ Default arguments are used to fill in arguments that were not provided at the callsite: ```tomo ->> increment(5) -= 6 +assert increment(5) == 6 ->> increment(5, 10) -= 15 +assert increment(5, 10) == 15 ``` **Note:** Default arguments are re-evaluated at the callsite for each function @@ -50,11 +48,9 @@ any unbound arguments, in order: func foo(x:Int, y:Text, z:Float64) return "x=$x y=$y z=$z" ->> foo(x=1, y="hi", z=2.5) -= "x=1 y=hi z=2.5" - ->> foo(z=2.5, 1, "hi") -= "x=1 y=hi z=2.5" +func main() + assert foo(x=1, y="hi", z=2.5) == "x=1 y=hi z=2.5" + assert foo(z=2.5, 1, "hi") == "x=1 y=hi z=2.5" ``` As an implementation detail, all function calls are compiled to normal @@ -157,10 +153,10 @@ func create_adder(n:Int -> func(i:Int -> Int)) n = -1 // This does not affect the adder return adder -... -add10 := create_adder(10) ->> add10(5) -= 15 + +func main() + add10 := create_adder(10) + assert add10(5) == 15 ``` Under the hood, all user functions that are passed around in Tomo are passed as |
