doc: a heck-ton more expressions for the sample file :)
This commit is contained in:
@@ -51,10 +51,61 @@ for i in 0 to:100 step:2 do
|
|||||||
end
|
end
|
||||||
|
|
||||||
cout put:"message" while x > 2.
|
cout put:"message" while x > 2.
|
||||||
cout put:"Count is {i}" for i in 0 to:100 step:2.
|
cout put:'Count is {i}' for i in 0 to:100 step:2.
|
||||||
|
|
||||||
z = do
|
z = do
|
||||||
x = 1.
|
x = 1.
|
||||||
y = 2.
|
y = 2.
|
||||||
^x + y
|
^x + y
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
class Person
|
||||||
|
/**
|
||||||
|
every message handler can have one or both of the following:
|
||||||
|
- a message name (in this case, 'init')
|
||||||
|
- a set of one or more parameters (wrapped in parentheses if the message
|
||||||
|
has a name)
|
||||||
|
|
||||||
|
each parameter has an internal name and an (optional) label, specified
|
||||||
|
as a pair of identifiers separated by a colon (:). the label comes
|
||||||
|
first, and is the name used by whoever is sending the message the
|
||||||
|
internal name comes second, and is used by the message handler itself as
|
||||||
|
a variable name.
|
||||||
|
|
||||||
|
you can omit the label for a parameter by specifying an underscore (_)
|
||||||
|
as the label, but this is not recommended. it looks weird, it obscures
|
||||||
|
the meaning of the message, and is really only supported for
|
||||||
|
compatibility with lambdas.
|
||||||
|
**/
|
||||||
|
- init(name:name age:age)
|
||||||
|
self::name = name.
|
||||||
|
self::age = age!
|
||||||
|
|
||||||
|
- test(param:data _:extra) | cout put:'Received {data}, {extra}'.
|
||||||
|
|
||||||
|
- name | ^self::name.
|
||||||
|
|
||||||
|
- age | ^self::age.
|
||||||
|
|
||||||
|
- ageInMonths | ^self::age * 12.
|
||||||
|
|
||||||
|
- setName:name | self::name = name.
|
||||||
|
|
||||||
|
- setAge:age | self::age = age.
|
||||||
|
|
||||||
|
- setAge:age inUnit:units
|
||||||
|
match units in
|
||||||
|
#years => self::age = age,
|
||||||
|
#months => self::age = age / 12,
|
||||||
|
#days => self::age = age / 365,
|
||||||
|
_ => self::age = 0
|
||||||
|
end!
|
||||||
|
|
||||||
|
- getAgeInUnit:units
|
||||||
|
^match units in
|
||||||
|
#years => self::age,
|
||||||
|
#months => self::age / 12,
|
||||||
|
#days => self::age / 365,
|
||||||
|
_ => 0
|
||||||
|
end!
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user