-
-
Notifications
You must be signed in to change notification settings - Fork 5
optional
To avoid null errors Angle offers the swift way
class car{
name:string // default
name:string! // required
year:date? //optional
}
Fields can be made required in function declarations via with
keyword or nested schemas:
age of car with year = car.year
age of car{year} = car.year
The scheme of the type can be adhoc and deep within function declarations:
arrival time of package{destination{address{zip or street}}} = calculate distance to zip …
To avoid redundancy, the type scheme leafs act as local symbols, so in the above example 'zip' is available to the block.
The untyped variant would just be
arrival time of package is calculate distance to its zip
Relying on deep accessor indexing
make optionally as unknown
default but enable way to specify the requirement of fields:
to get movie time of user with name and zip:...
to place order for user with last name and address:...
Julia style
movie-time (user:{name, address: zip} ) = ...
Nested optionality thanks to Rick Hickey from closure
These required attributes can also be inferred from the compiler:
peter{last-name=fox zip=1234}
movie-time(peter) // compiler warning/error: movie time requires peter to have a name
// extra: did you mean lastname?