[Nitro] [ANN] Facets 1.8 (RC)

transfire at gmail.com transfire at gmail.com
Sat Jan 27 21:32:30 EST 2007



On Jan 27, 7:26 pm, "Jonathan Buch" <j... at oxyliquit.de> wrote:
> Hi,
>
> > True, but we really need to get on with a new implementation of
> > annotations. The reason being that the old implementation is very
> > complicated and slow. It doesn't need to be so, but to fix it we have
> > to accept some reduction in syntax flexability. but that is actually
> > better (IMHO) b/c its simplier on the mind to have 1 or 2 ways to
> > write something rather than 4 or more.yep, all true.  (You may remember me cursing over this ;))
>
> The only things I used with annotations:
>
> Klass.ann :sym, {}
> Klass.attr_accessor :sym, SomeKlass, {}
>
> Klass.ann.sym
>
> So, one setter/update, one convenience function for Og, and one way to
> retrieve annotations.

Right. though your last example would be

   Klass.ann :sym

> Is there really a need to make a more 'complicated' interface?  (With
> ! and ?)  Is it feasable to 'reuse' .ann for objects too?  (As opposed
> to Classes and obj.annotation.)

it is possible to reuse ann of object too. i'll look at that.

unfortunately the use of #ann! (with exlimation) is needed in order to 
update annotations _in place_. the reason for this is that #ann 
returns all annotations, even those inherited from superclasses --so 
it is building this information on the fly, it's not just something 
that is statically stored in the class. the only way around this would 
be to build a special subclass of hash where all the write methods 
behaved differently than the read methods --i explored this option at 
one point and wrote rwdelegate.rb, which you can find in Facets. but 
that solution didn't seem very robust (though I don't recall the exact 
details now).

To make this more clear here is an example:

  class X
    ann :q, :a=>1
  end

  class Y < X
    ann :q, :b=>2
  end

  Y.ann :q   #=> { :a=>1, :b=>2 }
  Y.ann! :q   #=> { :b=>2 }

> Maybe Annotations can be a purely Hash-like structure, nothing fancy,
> with .ann just updating it..

that's basically what it is, but we need inheritance too.

> I don't really want to 'stir up' things further, but I think the easier
> annotations get, the better it is.  :P

agreed. and that's what we a going to achieve with this implementation 
-- simple as it can reasonably be.

T.



More information about the Nitro-general mailing list