at:tutorial:reflection
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:reflection [2008/08/01 14:42] – * tvcutsem | at:tutorial:reflection [2008/09/15 17:26] – * tvcutsem | ||
---|---|---|---|
Line 3: | Line 3: | ||
[[wp> | [[wp> | ||
- | The reflective model of AmbientTalk is based on [[http:// | + | The reflective model of AmbientTalk is based on [[http:// |
===== Mirrors ===== | ===== Mirrors ===== | ||
- | As we have already | + | |
+ | As we have mentioned in the introduction, | ||
+ | |||
+ | A convenience primitive exists that allows AmbientTalk programmers to acquire a mirror on an object without explicitly having to consult the mirror | ||
+ | |||
+ | Once a mirror has been created, it can be used to inspect | ||
< | < | ||
- | >def mirrorOnOne | + | def Point := object: { |
- | >>< | + | def x := 0; |
- | > | + | def y := 0; |
- | >> | + | def distanceToOrigin() { (x*x + y*y).sqrt }; |
- | <native method:<=>>, <native method:to:do:>, ...] | + | }; |
- | </code> | + | def p := Point.new(2,3); |
+ | // request a mirror on p via the mirror factory | ||
+ | > def mirrorOnP | ||
+ | >>< | ||
- | The code excerpt presented above uses the mirror to // | + | > |
+ | >> | ||
+ | </ | ||
- | When reflecting upon a user-defined | + | The code excerpt presented above uses the mirror to // |
< | < |
at/tutorial/reflection.txt · Last modified: 2010/11/16 16:32 by tvcutsem