Arc Forumnew | comments | leaders | submitlogin
1 point by absz 5967 days ago | link | parent

Yes, you can; it involves redefining sref. When you write (= (obj key) value), it becomes (sref obj value key). So in this case, you would write

  (redef sref (x v k)
    (if (isa x 'my-table)
      (let y (rep x)
        (annotate 'my-table (= y.k (upcase v))))
      (old x v k)))
Or, if you're using nex3's defm,

  (defm sref ((t x my-table) v k)
    (let y (rep x)
      (annotate 'my-table (= y.k (upcase v)))))
If you do this a lot, you could probably wrap a macro around it to eliminate some of the boilerplate.