Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package metaobjectTest
  2.  
  3. @doc{*
  4. addFieldInfo takes two parameters. The first is an identifier id.
  5. The second can be either 'counter' or 'names'. If it is 'counter',
  6. the metaobject creates a field
  7. let Int id = number of fields in the prototype;
  8. and a method
  9. func counter_id -> Int = number of methods in the prototype;
  10.  
  11. If the second parameter is 'names', the metaobject creates a field
  12. let Array<String> id = [ / * field names * / ];
  13.  
  14. This object tests the 'run until fixed point' feature of the Cyan MOP.
  15. This is because a metaobject may add fields and methods and therefore
  16. triggers changes in other metaobjects. The metaobject methods are
  17. called until they stop changing their outputs.
  18. *}
  19. @addFieldInfo(first, counter)
  20. @addFieldInfo(second, names)
  21. @addFieldInfo(third, counter)
  22. @addFieldInfo(fourth, names)
  23.  
  24. object AddFieldInfo
  25.  
  26. func aaa -> Int = 0;
  27. func bbb: Int n { }
  28. func ccc: Int n ddd: String s -> String = s ++ n;
  29.  
  30. var Int eee = 0;
  31. var String fff = "fff";
  32.  
  33. func run {
  34. printexpr first;
  35. Out println: "calling counter_first = " ++ counter_first;
  36. printexpr second;
  37. printexpr third;
  38. Out println: "calling counter_third = " ++ counter_third;
  39. printexpr fourth;
  40. }
  41.  
  42.  
  43. end
  44.  
  45. /*
  46. // this is the code added to prototype AddFieldInfo by the
  47. // four metaobjects
  48.  
  49. let Int first = 6;
  50. func counter_first -> Int = 7;
  51. let Array<String> second = [ "eee", "fff", "first", "second", "third", "fourth" ];
  52. let Int third = 6;
  53. func counter_third -> Int = 7;
  54. let Array<String> fourth = [ "eee", "fff", "first", "second", "third", "fourth" ];
  55.  
  56. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement