doc: update docs and sample files
This commit is contained in:
@@ -48,7 +48,6 @@ class Person
|
||||
compatibility with lambdas.
|
||||
**/
|
||||
- init(name:name age:age)
|
||||
var x.
|
||||
self::name = name.
|
||||
self::age = age!
|
||||
|
||||
@@ -80,7 +79,7 @@ class Person
|
||||
_ => 0
|
||||
end!
|
||||
|
||||
/* Properties are defined using the $ symbol.
|
||||
/* Properties are defined using the -> symbol.
|
||||
They accomplish two things:
|
||||
1) they make it easy to synthesize the -get: and -put:at: messages
|
||||
that the package dot syntax requires.
|
||||
@@ -109,7 +108,7 @@ class Person
|
||||
/* Without the lambda synthesis, the property would look like this:
|
||||
Note that this is the only time it is legal to access private fields
|
||||
via `self` from a lambda. */
|
||||
-> example-property |
|
||||
-> example-property-2 |
|
||||
get => [ ^self::val ],
|
||||
set => [ :x | self::val = x ].
|
||||
|
||||
@@ -119,23 +118,23 @@ class Person
|
||||
|
||||
If either the `set` or `get` elements are not provided, the property
|
||||
becomes read-only or write-only respectively */
|
||||
-> example-property-2 | get => 42.
|
||||
-> example-property-3 | get => 42.
|
||||
|
||||
/* A property can also be configured to act just like a regular variable,
|
||||
by setting the getter and setters to default implementations.
|
||||
|
||||
The default getter will return the value of a private member variable
|
||||
named by prepending two underscores to the property name
|
||||
(__exampleProperty3 in this case).
|
||||
(__example-property-4 in this case).
|
||||
|
||||
Similarly, the default setter will set the value of a private member
|
||||
variable named by prepending two underscores to the property name
|
||||
(__exampleProperty3 in this case) to the value provided to the setter. */
|
||||
-> example-property-3 (get, set)
|
||||
(__example-property-4 in this case) to the value provided to the setter. */
|
||||
-> example-property-4 (get, set)
|
||||
|
||||
/* Just like in the earlier examples, either `get` or `set` can be omitted
|
||||
to create a write-only or read-only property respectively */
|
||||
-> example-property-4 (get)
|
||||
-> example-property-5 (get)
|
||||
end
|
||||
|
||||
p1 = Person new(name:'John Doe', age:34).
|
||||
@@ -151,8 +150,8 @@ while i < 100 do
|
||||
i += 2
|
||||
end
|
||||
|
||||
for i in 0 to:100 step:2 do
|
||||
cout put:'Count is {i}'
|
||||
for x in 0 to:100 step:2 do
|
||||
cout put:'Count is {x}'
|
||||
end
|
||||
|
||||
/**
|
||||
@@ -223,11 +222,11 @@ pkg[0] = 16.
|
||||
/* All of these accesses are equivalent */
|
||||
pkg['x'] = 32.
|
||||
pkg->x = 32.
|
||||
pkg put:32 at:'x'.
|
||||
pkg at:'x' put:32.
|
||||
|
||||
index = 'x'.
|
||||
pkg[index] = 32.
|
||||
pkg put:32 at:index.
|
||||
pkg at:index put:32.
|
||||
|
||||
/**
|
||||
this syntax, and the pkg.* instructions that it translates to, is
|
||||
@@ -274,7 +273,7 @@ end
|
||||
following criteria:
|
||||
a) is an Iterator object; or
|
||||
b) implements the Iterator protocol; or
|
||||
c) understands the -iterator message, and returns an object that itself
|
||||
c) understands the -get-iterator message, and returns an object that itself
|
||||
conforms to a) or b)
|
||||
**/
|
||||
|
||||
@@ -311,7 +310,7 @@ end
|
||||
on:$err:number-format do:[ :err :data |
|
||||
cout put:'Cannot parse integer string ({err})'
|
||||
];
|
||||
onError:[ :err :data |
|
||||
on-error:[ :err :data |
|
||||
cout put:'Error {err} occurred ({data})'
|
||||
];
|
||||
call.
|
||||
|
||||
Reference in New Issue
Block a user