User Tools

Site Tools


at:tutorial:metaprogramming

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
at:tutorial:metaprogramming [2007/07/27 07:45]
jdedecker
at:tutorial:metaprogramming [2008/08/01 14:31]
tvcutsem *
Line 25: Line 25:
  
 ==== Quasiquoting and splicing ==== ==== Quasiquoting and splicing ====
 +Quasiquoting and splicing are an advanced and powerful metaprogramming techniques that control the evaluation process and allow one to manipulate the evaluation process of the abstract syntax tree.
  
-=== Qouting ===+=== Quoting ===
  
 Any valid AmbientTalk expression can be quoted. This prevents the expression from being evaluated. Instead, it is returned literally. Any valid AmbientTalk expression can be quoted. This prevents the expression from being evaluated. Instead, it is returned literally.
Line 63: Line 64:
 == Expressions ==  == Expressions == 
  
-To quote a complete expression, it has to be wrapped in parantheses:+To quote a complete expression, it has to be wrapped in parentheses:
  
 <code> <code>
Line 101: Line 102:
 With this construct, all the elements of the literal table are evaluated. By quoting a literal table, all the elements are quoted instead of evaluated: With this construct, all the elements of the literal table are evaluated. By quoting a literal table, all the elements are quoted instead of evaluated:
 <code> <code>
->def tab := `[ 1+2, 3+4, 5+6 ]+>def anotherTab := `[ 1+2, 3+4, 5+6 ]
 >>[1.+(2), 3.+(4), 5.+(6)] >>[1.+(2), 3.+(4), 5.+(6)]
 </code> </code>
Line 194: Line 195:
 >read: "1+2" >read: "1+2"
 >>1.+(2) >>1.+(2)
->eval: `(1+2) in: self+>def result := eval: `(1+2) in: self
 >>3 >>3
->print: self +>print: result 
->>"<object:8322247>"+>>"3"
 </code> </code>
  
Line 204: Line 205:
 <code> <code>
 >def o := object: { def x := 4 } >def o := object: { def x := 4 }
->><object:3281169>+>><obj:{super,super:=,x,x:=}>
 >eval: `x in: o >eval: `x in: o
 >>4 >>4
 </code> </code>
at/tutorial/metaprogramming.txt · Last modified: 2009/11/21 07:44 by tvcutsem