[stringtemplate-interest] v4 renderers
Terence Parr
parrt at cs.usfca.edu
Thu Dec 23 09:58:49 PST 2010
On Dec 22, 2010, at 2:10 PM, Udo Borkowski wrote:
>> Look ok? Same would work for registerModelAdaptor(type, adap), right? Upon <a.p> and a.getClass() is instanceof or implements type, then I'd ask adap how to get p from 'a', right? Later I can cache a.getClass -> adap mapping.
>
> Rather than caching a.getClass -> adap I would ask adap for an object I could use for caching (and accessing a property value). This is because it may still be expensive for the adapter to calculate the property value, but easier if some "calculation" is already done (and only done once).
but before i can ask an adaptor for it's object->Method cache, i have to find the adaptor, which is O(n); i should cache that right?
> E.g. imagine you want to implement the current property access behaviour (as defined by Interpreter#getObjectProperty(…)) by an adapter. This would require first checking for the "Map" case, then the "ST" case, then the "getFoo()" case, then the "isFoo()" case and finally the field "foo" case. Actually this only needs do be done once per class and property(name).
right. that's the 2nd level cache, if you will. first is finding the adap :)
> Therefore I defined one "Access class" for each of these cases and store the proper one with each class and property (name) pair. (Undefined properties map to a unique "UNDEFINED" accessor).
cool. i'm thinking same thing. Define adap for Map, ST, and Object (default).
let me code something and see how it smells.
Ter
More information about the stringtemplate-interest
mailing list