Languages-beta : SL-4-Definitions.cbs | PRETTY | PDF
Language "SL"
4 Function definitions
Semantics
declare[[ FunDef*:fun-def* ]] : => environments
Rule
declare[[ 'function' Id '(' IdList? ')' Block ]] =
{ id[[Id]] |->
function closure
scope(initialise-local-variables,
sequential(
pass-list[[IdList?]],
handle-return(exec[[Block]]))) }
Rule
declare[[ ]] = map( )
Rule
declare[[ FunDef FunDef+ ]] =
collateral(declare[[FunDef]], declare[[FunDef+]])
Parameter lists
Semantics
pass-list[[ IdList:id-list? ]] : lists(values) => null-type
Rule
pass-list[[ ]] = null-value
Rule
pass-list[[ Id ]] =
local-variable-initialise(id[[Id]], checked head given)
Rule
pass-list[[ Id ',' IdList ]] =
sequential(
local-variable-initialise(id[[Id]], checked head given),
give(checked tail given, pass-list[[IdList]]))