at:tutorial:objects
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
at:tutorial:objects [2007/07/09 20:53] – clarified tvcutsem | at:tutorial:objects [2007/07/09 21:00] – small tvcutsem | ||
---|---|---|---|
Line 4: | Line 4: | ||
In AmbientTalk, | In AmbientTalk, | ||
classes. Rather, they are either created ex-nihilo or by cloning | classes. Rather, they are either created ex-nihilo or by cloning | ||
- | and adapting existing objects, | + | and adapting existing objects, |
The following code illustrates the ex-nihilo creation of an object: | The following code illustrates the ex-nihilo creation of an object: | ||
< | < | ||
- | > def point := object: { | + | def Point := object: { |
- | def x := 0; | + | def x := 0; |
- | def y := 0; | + | def y := 0; |
- | def init(aX,aY) { | + | def init(aX,aY) { |
- | x := aX; | + | x := aX; |
- | y := aY; | + | y := aY; |
- | }; | + | }; |
- | def sumOfSquares() { x*x + y*y }; | + | def sumOfSquares() { x*x + y*y }; |
- | } | + | } |
</ | </ | ||
- | As all definitions in AmbientTalk, objects, fields and methods are defined using the **def** keyword. Fields are defined using a '' | + | The above code defines an // |
+ | |||
+ | In the example above, the state of the point object is composed of '' | ||
< | < | ||
As already explained in the [[at: | As already explained in the [[at: | ||
- | </ | ||
- | In the example above, the state of the '' | + | For Smalltalk/ |
+ | </ | ||
===== Sending messages ===== | ===== Sending messages ===== |
at/tutorial/objects.txt · Last modified: 2013/05/17 20:23 by tvcutsem