Re: funcallable-standard-class question



Michal Krupka wrote:
In my little experimental project, I need to define a class with funcallable-standard-class as a metaclass and call the function set-funcallable-instance-function on its instances. I want to make it work in all main CL implementations.

SBCL and LispWorks seems to work OK, prompt.franz.com generates error "Class #<STANDARD-CLASS STANDARD-OBJECT> is not yet finalized." when evaluating class definition:

(defclass test ()
()
(:metaclass funcallable-standard-class))

Try one of these

(defclass test (standard-generic-function)
()
(:metaclass clos:funcallable-standard-class))

(defclass test (generic-function)
()
(:metaclass clos:funcallable-standard-class))

depending on exactly what you are trying to do.

I don't know what the "other implementions" are doing, and whether you can actually construct a callable generic function without specifying the superclasses of your test class, but according to the normal clos definitions objects or your original class would be standard-objects, not funcallable-standard-objects, much less generic-functions. A
standard-object doesn't support being funcalled, etc.

The error you received was cryptic, but is being signaled by mop:validate-superclass. Some history: The X3J13 subcommittee that drafted the COS standard recommended back in 1989 that X3J13 approve the CLOS standard as an addition to the language, but not approve the MOP specification since there was no experience using it and there was considerable doubt that all the details were correct and consistent. In fact the MOP spec has proven pretty good. but there are a number of non-obvious brainos that aren't so very important since they don't affect normal code, or even code very distant from being normal code. One of these braino areas surrounded validate-superclass. There were some email discussions with Gregor and others back then that suggested some improvements to the tests performed by validate-superclass. ACL tries to implement them (although they are certainly not yet entirely correct -- it's an area that is hard to think about!) There is a residual question here, whether specifying a metaclass of funcallable-standard-class should modify the specified superclass list as required by the implementation, but I've survived this long without thinking hard about this and hope ti live out the rest of my days wthout having to do so.
.



Relevant Pages

  • funcallable-standard-class question
    ... I need to define a class with funcallable-standard-class as a metaclass and call the function set-funcallable-instance-function on its instances. ... I want to make it work in all main CL implementations. ... In my package definition I use the following to import MOP symbols: ...
    (comp.lang.lisp)
  • Re: funcallable-standard-class question
    ... funcallable-standard-class as a metaclass and call the function set-funcallable-instance-function on its instances. ... I want to make it work in all main CL implementations. ... the usual meta question applies: What do you actually want to achieve? ...
    (comp.lang.lisp)