Re: class definition dependencies

From: Christian Lynbech on satellite <chl_at_tbit.dk>
Date: Wed, 24 Feb 1999 11:37:30 +0100 (CET)

>>>>> "Brian" == Brian Denheyer <briand_at_deldotd.com> writes:

Brian> Unfortunately, I think that I was right the first time and that
Brian> "mix-ins" on the methods like that are going to require the methods
Brian> all go into one file or the other, or better yet into some 3rd file.
Brian> If you have a method which works on different classes like that,
Brian> sometimes its not so obvious which file(s) it should go in.

Alternatively you may be able to get by by doing a forward declaration
of the missing class. That is you should be able to do something like
the following in A.scm

        (provide "A")
        (define-class A ())
        (require "B")
        (define-class A ....);real definition

and keep B.scm as usual.

STk does support redefining classes so defining new classes in B that
refers to the (currently empty) class A should work, I think.At least
the following quick test (with guile, but it uses the same
implementation of OO) seems to support that:

        (define-class A () ()) ;forward declaration
        (define-class B () (b1))
        (define-method test ((x A) (y B)) (list x y))
        (define-method test (x y) ())

        (test 1 2)
        ;=> ()

        (test (make A) (make B))
        ;=> (#<A 4011dfb8> #<B 4011d4f8>)

        (define-class A () (a1)) ;redefinition
        (test (make A) (make B)) ;we still hit the method
        ;=> (#<A 4011cac8> #<B 4011bf68>)


---------------------------+--------------------------------------------------
Christian Lynbech | Telebit Communications A/S
Fax: +45 8628 8186 | Fabrik 11, DK-8260 Viby J
Phone: +45 8628 8177 + 28 | email: chl_at_tbit.dk --- URL: http://www.telebit.dk
---------------------------+--------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - petonic_at_hal.com (Michael A. Petonic)
Received on Wed Feb 24 1999 - 11:38:54 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST