at:tutorial:objects
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:objects [2007/07/02 12:49] – jorge | at:tutorial:objects [2007/07/02 14:16] – jorge | ||
---|---|---|---|
Line 49: | Line 49: | ||
Every object understands the message '' | Every object understands the message '' | ||
- | AmbientTalk also provides a '' | + | AmbientTalk also provides a '' |
< | < | ||
Line 67: | Line 67: | ||
> def point3D := extend: point with: { | > def point3D := extend: point with: { | ||
def z := 0; | def z := 0; | ||
- | def sumofsquares() { | + | def sumOfSquares() { |
- | super.sumofsquares() + z*z | + | super^sumOfSquares() + z*z |
} | } | ||
} | } | ||
Line 78: | Line 78: | ||
> def point3D := share: point with: { | > def point3D := share: point with: { | ||
def z := 0; | def z := 0; | ||
- | def sumofsquares() { | + | def sumOfSquares() { |
- | super.sumofsquares() + z*z | + | super^sumOfSquares() + z*z |
} | } | ||
} | } | ||
Line 88: | Line 88: | ||
< | < | ||
- | > def OpenConnection | + | > def openConnection |
- | def ClosedConnection | + | > def closedConnection |
- | def Connection | + | > def connection |
- | def open() { | + | def open() { |
- | super := OpenConnection.new(); | + | super := openConnection.new(); |
}; | }; | ||
def close() { | def close() { | ||
- | super := ClosedConnection.new(); | + | super := closedConnection.new(); |
}; | }; | ||
} | } | ||
</ | </ | ||
- | ===== First-class Delegation ===== | + | <note important> |
+ | In AmbientTalk, | ||
+ | </ | ||
+ | ===== First-class delegation ===== | ||
+ | AmbientTalk provides an explicit delegation operator '' | ||
+ | |||
+ | < | ||
+ | > def point3D := extend: point with: { | ||
+ | def z := 0; | ||
+ | def init(aX, aY, aZ) { | ||
+ | super^init(aX, | ||
+ | z := aZ; | ||
+ | }; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | A message sent to an object using the '' | ||
===== Encapsulation ===== | ===== Encapsulation ===== |
at/tutorial/objects.txt · Last modified: 2013/05/17 20:23 by tvcutsem