Re: Ensuring a method exists



On 27 Sep 2006 15:02:48 -0700, "Javier" <javuchi@xxxxxxxxx> wrote:

Going on with this matter, and because I don't fully understand all the
answers you have done:

How would you implement an interface using CLOS with lots of different
methods? For example:

interface Collection {
void add (Object o);
void remove (Object o);
...
}

In CLOS terms, you think of the add, remove, etc operations comprising
a protocol. You use DEFGENERIC to define a generic function for each
operation; the resulting set of generic functions embodies the logical
protocol. Then given classes for which those operations apply,
you use DEFMETHOD to provide implementations. Note that CLOS methods
belong to generic functions, not to classes.

There is no construct in CLOS that corresponds to the Java interface
syntax. The concept of a protocol is something you would describe in
documentation, but it is not manifested as any Lisp object that you
can manipulate.

--
Jack Unrue
.



Relevant Pages

  • Re: Ensuring a method exists
    ... How would you implement an interface using CLOS with lots of different ... void remove; ... CLOS because Lisp resolves this problem in a different way, ...
    (comp.lang.lisp)
  • Re: alternative to CLOS
    ... i'm curious -- i'd like to see alternative object system ... i have a problem -- CLOS does not work well in ABCL. ... CLOS is quite bloated so i'm unlikely to fix it myself. ... work with new module as long as implements same module interface. ...
    (comp.lang.lisp)
  • Re: Ensuring a method exists
    ... How would you implement an interface using CLOS with lots of different ... void remove; ... Since Common Lisp is dynamically typed, you don't have to worry about all these things. ...
    (comp.lang.lisp)
  • [ANN] OOPSLA05 CLOS tutorial
    ... OOPSLA'05 tutorial on generic functions and the CLOS Metaobject Protocol ... In CLOS, methods belong to generic functions instead of classes, and those generic functions select and execute the correct method according to the types of the arguments they receive. ...
    (comp.lang.lisp)
  • Re: Sample for Metaprogramming
    ... So, basically, instead of real methods, CLOS just uses. ... of generic functions in CLOS instead of using a message passing system ... | Furthermore, in Common Lisp, arithmetic operators are already ... In this way, the Object System ...
    (comp.lang.ruby)