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/27 10:15] – added tvcutsemat:tutorial:objects [2007/07/27 16:31] – * tvcutsem
Line 284: Line 284:
 </code> </code>
  
-The rationale is that ''x'' is bound to a field, so performing ''o.x'' simply selects the value from the field. However, what happens if we evaluate ''o.x()'' intead?+The rationale is that ''x'' is bound to a field, so performing ''o.x'' simply selects the value from the field. However, what happens if we evaluate ''o.x()'' instead?
  
 <code> <code>
Line 291: Line 291:
 </code> </code>
  
-When explicitly //applying// the ''x'' field, the interpreter //does// execute the block closure stored in ''x''. If the interpreter would not behave in this way, but rather have ''o.x()'' return the closure as well, then the programmer would be required to write ''(o.x)()'', which is a bit clumsy. In essence, the rule remains simple: code of the form ''o.x'' either returns the value of a //field// ''x'' or executes a //method// ''x''. Whether or not the field contains a closure does not change the semantics.+When explicitly //applying// the ''x'' field, the interpreter //does// execute the block closure stored in ''x''. If the interpreter would not behave in this way, but rather have ''o.x()'' return the closure as well, then the programmer would be required to write ''(o.x)()'' to apply the closure, which is a bit clumsy. In essence, the rule remains simple: code of the form ''o.x'' either returns the value of a //field// ''x'' or executes a //method// ''x''. Whether or not the field contains a closure does not change the semantics.
  
 ==== UAP and Assignment ==== ==== UAP and Assignment ====
Line 317: Line 317:
   // and a mutator method seconds:=(v)   // and a mutator method seconds:=(v)
  
-  def minutes() { (seconds / 60}; +  def minutes() { seconds / 60 }; 
-  def hours()   (seconds / 3600};+  def hours()   { seconds / 3600 };
  
   def minutes:=(mins) {   def minutes:=(mins) {
Line 334: Line 334:
 >> 3600 >> 3600
 > time.seconds := 180 > time.seconds := 180
 +>> 180
 > time.minutes > time.minutes
 >> 2 >> 2
at/tutorial/objects.txt · Last modified: 2013/05/17 20:23 by tvcutsem