- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 4
argument
pannous edited this page Sep 22, 2021
·
3 revisions
arguments are parameters to functions and closures
In angle they can be symbolic and subject to structural matching
They take the same semantics of optional, required, constant and mutable as other variables:
to call person{name?, phone number, email?, mutable status} do
telephone.dial person.phone
person.status = called
unused optional fields can be omitted. Fields which are required in the callers object can be optional in the callees parameter and vice versa: an object of the following class can still be passed to the above call function:
class person{
name,
phone?
}
since the name is always provided it is OK to fill the optional name? parameter of the call function however it is required to fill the phone parameter to call the function:
person john:{name:"Jonathan" phone:"899-573-5842"}
call john// ok
call person {name:"Dick"} // compile error: missing argument field phone
default values are allowed on all parameters.