call in WebAssembly
Private helpers by $name; only exports face the host.
(module
;; call names another function in the module; only the exported one
;; is visible to the host.
(func $celsius_to_f (param $c i32) (result i32)
(i32.add
(i32.div_s (i32.mul (local.get $c) (i32.const 9)) (i32.const 5))
(i32.const 32)))
(func (export "spread_f") (param $lo_c i32) (param $hi_c i32)
(result i32)
(i32.sub
(call $celsius_to_f (local.get $hi_c))
(call $celsius_to_f (local.get $lo_c)))))
How it works
$celsius_to_fhas no export — it exists for the module alone.call $celsius_to_fpushes arguments first, folded style.spread_fcalls it twice and subtracts the results.
Keywords and builtins used here
callexportfunci32moduleparamresult
The run, in numbers
- Lines
- 13
- Characters to type
- 407
- Tokens
- 85
- Three-star pace
- 65 tpm
At the three-star pace of 65 tokens a minute, this run takes about 78 seconds.
Step 1 of 3 in Calls, step 13 of 28 in Language basics.