Re: [CLOS] Ensuring a method exists



Jack Unrue wrote:
On Wed, 27 Sep 2006 09:40:18 +0200, Didier Verna <didier@xxxxxxxxxxxxx> wrote:
I'd like to ensure that if somebody writes a derived class:

(defclass derived (base) ...)

she also provides a method for this class:

(defmethod foo ((a derived) (b derived)) ...)

Perhaps this constraint should be checked via a wrapper for
calling foo and use that where foo would normally be called
directly? Or use some aspect-oriented approach (maybe AspectL)?

A wrapper would have the disadvantage that the check would be done on each call.

And don't use AspectL for this. ;) Or better, don't use AspectL for anything serious. AspectL was an experiment to better understand AOP. Except for very few cases, all of AspectL's functionality is provided in better and safer ways in ContextL.

And no, ContextL probably also doesn't give you any advantages for this particular case. CLOS is already powerful enough here.


Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
.



Relevant Pages

  • Re: [MOP] How do I add an extra slot to a class?
    ... Two reasons why I wouldn't particularly like to use this solutions: ... If you get a parameter to one of the AspectL functions wrong, it is quite likely that your system becomes unusable. ... I could have added some parameter checking, but that would have been a lot of work, and I am convinced that ContextL gives you much cleaner abstractions to essentially achieve the same. ... You could do the same in your code: For each view-class, actually create a stub class that inherits from a view-class and an assocation-class. ...
    (comp.lang.lisp)
  • Re: Art of MetaObject Protocol and Reflection (Java, C#, etc.)
    ... I don't know if that is also related to AspectL. ... Terms are not very familiar to me as an Internet programmer so I think first I must understand those "cross cutting concerns", "aspects" and maybe then I can understand context oriented programming and what kind of advantages it brings to real life situations. ... ContextL just happens to be implemented via the CLOS MOP. ...
    (comp.lang.lisp)
  • Re: Dynamic function bindings
    ... The section about "context-oriented programming" at http://p-cos.net/research.html contains three papers that all show variations on how to apply dynamic scoping to concepts other than variables. ... The paper about AspectL in the "aspect-oriented programming" section also talks about "special generic functions", ... ContextL provides almost all the features of AspectL, but in cleaner and more efficient ways. ...
    (comp.lang.lisp)