field - pannous/warp GitHub Wiki
field
Field, property, aspect and member denote almost the same thing: a part of an object.
The only difference between a field and a property is that a property has get and set methods.
Because functions in angle can be invoked without parenthesis, the use of properties, fields and functions are at times opaque(transparent?) to the developer.
A person has the aspects name and address, written in angle as:
person{
name
address
}
As always types can be omitted if the property name is equal to its type:
Otherwise fields can be typed like variables: With prefixed type
person{
Name secret_name
}
Or with suffixed type:
person{
secret Name
}
Or with coloned type:
person{
secret:name
}
Capitalized types are mere convention when splitting a property name and its type.
They become semantically meaningful if both Secret and Name in secret Name are types.
Todo:
DoubleType types:
what if both Secret and Name are types in secret name?
Multiple inheritance? postpone this problem.
Todo: DoubleType coloned type:
person{
secret::name // as in which other languages?
}
Todo: in and as operators for typing (not yet under warp eval):
person{
age in years
name as string
}
Dashes
A dash between a field and a name is never a silent subtraction. Without a field phone-number it is an error:
p = {phone: 5}
number = 2
p.phone-number // error: p has no field phone-number; fix: p.phone - number