Another source of excess checks in the IMP code is the decorators. There are three reasons to create them - you have a new particle and need to add fields to it - you have a particle which may or may not have the needed fields - you have a particle which has the needed fields (you know already)
We currently support the first two and have no way of expressing the third. In addition, the current syntax is kind of annoying.
I propose adding constructors to the decorators from Particle* to express the third. The constructors would have an assertion that they particles have the correct attributes (but this assertion would go away in non debugged code). Thoughts?
Daniel Russel wrote: > Another source of excess checks in the IMP code is the decorators.
True.
> I propose adding constructors to the decorators from Particle* to > express the third.
I'm not sure I follow you - you want to add extra methods to Particle? It doesn't seem like that would scale - external modules could add their own decorators, and obviously they can't modify the Particle base class.
> The constructors would have an assertion that they > particles have the correct attributes (but this assertion would go > away in non debugged code). Thoughts?
If you replace checks with assertions, the Python interface would need to have some checking in it, because we don't want to crash the interpreter if somebody has a typo in their script and uses the wrong decorator.
Ben
>> I propose adding constructors to the decorators from Particle* to >> express the third. > > I'm not sure I follow you - you want to add extra methods to Particle? > It doesn't seem like that would scale - external modules could add > their > own decorators, and obviously they can't modify the Particle base > class. No, an extra method to decorator: a constructor from the particle*.
> If you replace checks with assertions, the Python interface would need > to have some checking in it, because we don't want to crash the > interpreter if somebody has a typo in their script and uses the wrong > decorator. Agreed. I think you can do things like wrap all *Decorator::*Decorator calls, right? If that is so, it is pretty easy since there is already a method on the decorator to check if a Particle* is OK.
participants (2)
-
Ben Webb
-
Daniel Russel