Re: [CLOS] Ensuring a method exists



Didier Verna <didier@xxxxxxxxxxxxx> writes:

That's a nice solution but it has one caveat (my question was probably
not clear enough about this): your trick checks for the existence of a method
only for the class you instanciate, and not for the subclasses.

So imagine having A <- B and creating only instances of B. The lack of method
for class A would go unnoticed. But I want the check for the whole hierarchy
(consider for instance that I'm using the AND method combination type and I'm
expecting an implementation for all the classes).

RED FLAG!

You shouldn't be subclassing something if you don't want to get its
functionality as default. You shouldn't be using subclassing at all
here. I suspect that if you use my library do define a protocol like
VALIDATABLE and have method on the VALIDATE g-f as part of the protocol,
you'll get what you want. Then VALIDATABLE wouldn't be a class, so you
wouldn't get any functionality from it, just the requirement of that
method being implemented for VALIDATABLE classes.

So maybe you're just using the wrong terminology, as you haven't been
exposed to the Lisp concept of "protocols" which are analgous to the
Java concept of "interfaces" except that protocols aren't part of the
language officially (as it's rather tricky to force anything to be
around before anything else in a multiple-dispatch, dynamic OO
language). My library just allows a declaration of what a class
conforming to a protocol should support and a function to test whether
it has gotten to that point after you've loaded all appropriate code.
Note that in CL, you can add functionality to a class in a different
library. Think about dispatching on INTEGER; effectively, you've now
given the INTEGER class more functionality than it may have before. This
is why my library allows you to declare protocols both inside the
defclass form as well as outside (to parallel the method definitions
that can occur in both places, as well).

--
Rahul Jain
rjain@xxxxxxxx
Professional Software Developer, Amateur Quantum Mechanicist
.



Relevant Pages

  • Re: Designing a protocol for the first time
    ... involved and you will have to validate it. ... I don't see any need to simulate the protocol using other than the actual hardware and software in this case. ... You will have only to pad the last frame. ... So either it must include a count of the points to render so that the target knows not to attempt to render null data points, or it must include a count of the points so that the protocol knows when the end of the data has been reached. ...
    (comp.arch.embedded)
  • Re: HardBound and SoftBound
    ... Structure overlays with embedded bit fields? ... Similar functionality ... can be done with bit extract/set accessors, ... By far the cleanest way of doing this is to separate your protocol ...
    (comp.arch)
  • Re: Universally composable protocol....
    ... Functionality is just any task for example, committment, zkp etc. ... F-hybrid model means the parties involved in the protocol have access ...
    (sci.crypt)
  • Re: adding http:// to website in form
    ... If you have a guarantee that all resources will be for http protocol ... If the OP has no way to validate on the server (which would be ...
    (comp.lang.javascript)
  • Re: [CLOS] Ensuring a method exists
    ... hierarchy (consider for instance that I'm using the AND method combination ... functionality as default. ... Consider the classic binary method example Point <- ColorPoint with ... library do define a protocol ...
    (comp.lang.lisp)