(param...)
Declare a parameter for a code block. This is used to state what values need to be placed onto the stack before the code block is entered. This is used with (func...), (if...), (loop...) and (block...).

Syntax

(param $label type1 typeN)

Parameters

$label Optional
The name of the parameter. Each parameter is also given an index. You can reference the parameter using either the label or the index value.
type1
The data type the parameter uses. There must be at least one data type.
typeN Optional
You can list as many different types as you want. Only the first type will be linked to the label used. All the other ones can only be accessed using their index. You normally only have one data type per (param...) object, and if more than one parameter is needed then you would have a separate object for each one.

Examples

(func $add (param $first i32) (param $second i32) (result i32)
  ;; Add first and second parameters together and return result
  local.get $first
  local.get $second
  i32.add
)
(func $add (param i32 i32) (result i32)
  ;; Add first and second parameters together and return result
  local.get 0
  local.get 1
  i32.add
)
(func $testAdd
  ;; Push parameters onto the stack
  i32.const 42
  i32.const 101

  ;; Call the $add function
  call $add

  ;; The stack contains the returned result of an i32 value of 143
)