User Tools

Site Tools


at:tutorial:objects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:objects [2007/07/09 21:00] – small tvcutsemat:tutorial:objects [2007/07/09 21:03] – *stressed tvcutsem
Line 27: Line 27:
 As already explained in the [[at:tutorial:basic|basic programming]] part of the tutorial, AmbientTalk not only supports traditional canonical syntax (e.g. ''o.m(a,b,c)'') but also keyworded syntax (e.g. ''o.at: key put: value''). Keyworded syntax can be used both for method definitions and for message sends. As already explained in the [[at:tutorial:basic|basic programming]] part of the tutorial, AmbientTalk not only supports traditional canonical syntax (e.g. ''o.m(a,b,c)'') but also keyworded syntax (e.g. ''o.at: key put: value''). Keyworded syntax can be used both for method definitions and for message sends.
  
-For Smalltalk/Self programmers: note that a keyworded message send does require a message sending operator (like ''.'') in between the receiver and the message, which is different from Smalltalk and Self. As will be described in later chapters, AmbientTalk features more than one message sending operator, so the programmer must explicitly specify an operator.+For Smalltalk/Self programmers: note that a keyworded message send does require a message sending operator (like ''.'') in between the receiver and the message, which is different from Smalltalk and Self. As will be described in later chapters, AmbientTalk features more than one message sending operator, so the programmer must explicitly specify which one to use.
 </note> </note>
  
Line 34: Line 34:
  
 <code> <code>
-point.x +Point.x 
->>2+>>0
 > point.sumOfSquares() > point.sumOfSquares()
->>13+>>0
 </code> </code>
  
-This code shows two messages sent to the ''point'' object defined above in this section. The ''x'' message acts as an accessor for the ''x'' field. The ''sumOfSquares'' message selects the ''sumOfSquares'' method and evaluates its body.+This code shows two messages sent to the point object defined above. The ''x'' message acts as an accessor for the ''x'' field. The ''sumOfSquares'' message looks up the ''sumOfSquares'' method in the object and applies it. 
 + 
 +Note that the "prototypical" point object defined above can act as a stand-alone object. This is different from a class in a class-based language, which often requires the use of ''static'' fields or methods to be used stand-alone.
  
 ===== Cloning and instantiation ===== ===== Cloning and instantiation =====
at/tutorial/objects.txt · Last modified: 2013/05/17 20:23 by tvcutsem