Title: Theory / Unimportant / CS / Programming / oCaml / Manual{ / 04 Labels;
Tags: hasNotNewEffectReturnsMeaning FromInstruction computer_to_instruction some_instruction declaration type

Typ: label_1:type_1 -> ... -> label_n:type_n ->typeOut
Meaning: The type of a function with n parameters, of type type_i, with label label_i
Language: ocaml
Chapter: 4
Section: 1

Instruction: f ~label'_1:expr_1 ... ~label'_n':expr_n'
Effect: Executing the expri, applying f where the arguments labelled by label'_i are interpreted by the value of expr_i.
In case of equal labels, the arguments are applied in the given order.
unlabelled arguments are treated last
Language: ocaml
Chapter: 4
Section: 1
Variables: f: label_1:type_1 -> ... -> label_n:type_n ->typeOut
Assuming: The label'_i are a submultiset of the label_i

Instruction: let f ~label'_1:var_1 ... ~label'_n:var_n =code
Meaning: Define a function, whose i-th argument's label is label_i. When called, it executes code where var_i is interpreted as the argument labbelled by label_i.
Language: ocaml
Chapter: 4
Section: 1

Instruction: ~label_i
Effect: Syntactic sugar for ~label_i:label_i
Language: ocaml
Context: labelled functions parameter
Chapter: 4
Section: 1

Instruction: var_i
Effect: Syntactic sugar for ~:var_i, where the empty label is just a label
Language: ocaml
Context: labelled functions parameter
Chapter: 4
Section: 1

Instruction: ?(label=expr)
Effect: An optional argument whose type is the one of expr
Language: ocaml
Context: labelled functions parameter
Chapter: 4
Section: 1

Instruction: ?var
Effect: An optional argument whose type is 'a option
Language: ocaml
Context: labelled functions parameter
Chapter: 4
Section: 1

Instruction: ?var
Effect: if var was not explicitly given when the current function is called, it is not given to the function which is going to be called, otherwise it is given
Language: ocaml
Chapter: 4
Section: 1
Where to use it: call of labelled function
Assuming: var is given as an optional argument,