From: Leo on 19 Jun 2010 13:56 On 2010-06-17 00:48 +0100, Barry Margolin wrote: > You could define your own subclasses of each of the provided classes, > that also inherit from fsolve-1-er: > > (defclass my-multi-dimensional-root-solver-f > (fsolve-1-er multi-dimensional-root-solver-f)) > > (defclass my-multi-dimensional-root-solver-fdf > (fsolve-1-er multi-dimensional-root-solver-fdf)) Thank you for this. If I need to write more methods for both classes, this is certainly a good solution. Leo
From: Leo on 19 Jun 2010 14:02 On 2010-06-18 12:00 +0100, Pascal Costanza wrote: > (defmethod make-instance > ((class-name (eql 'multi-dimensional-root-solver-f)) > &rest initargs) > (apply #'make-instance > 'my-multi-dimensional-root-solver-f initargs)) > > (defmethod make-instance > ((class-name (eql 'multi-dimensional-root-solver-fdf)) > &rest initargs) > (apply #'make-instance > 'my-multi-dimensional-root-solver-fdf initargs)) > > This is not fully standard-compliant, and may not fully work in all > corner cases, but should be good enough for many practical purposes. > > (If the CLOS MOP is available, there are other ways to achieve similar > effects.) > > > Pascal This didn't occur to me at all. Sounds very interesting. I have closer-mop loaded (I use sbcl and ccl). Could you elaborate on this approach? Thanks. Leo
From: Leo on 19 Jun 2010 14:05 On 2010-06-16 20:11 +0100, Thomas A. Russ wrote: > Well, Barry's suggestion would be the best case, but it won't help you > if you are using a library which already defines these classes. You > wouldn't be able to add a superclass without redefining the classes. > > So you are then left with other potential solutions: [...] Thanks for the great sum up. Leo
From: Pascal Costanza on 19 Jun 2010 15:12 On 19/06/2010 20:02, Leo wrote: > On 2010-06-18 12:00 +0100, Pascal Costanza wrote: >> (defmethod make-instance >> ((class-name (eql 'multi-dimensional-root-solver-f)) >> &rest initargs) >> (apply #'make-instance >> 'my-multi-dimensional-root-solver-f initargs)) >> >> (defmethod make-instance >> ((class-name (eql 'multi-dimensional-root-solver-fdf)) >> &rest initargs) >> (apply #'make-instance >> 'my-multi-dimensional-root-solver-fdf initargs)) >> >> This is not fully standard-compliant, and may not fully work in all >> corner cases, but should be good enough for many practical purposes. >> >> (If the CLOS MOP is available, there are other ways to achieve similar >> effects.) >> >> >> Pascal > > This didn't occur to me at all. Sounds very interesting. I have > closer-mop loaded (I use sbcl and ccl). Could you elaborate on this > approach? Thanks. Very roughly: (let ((some-class (find-class 'some-class))) (reinitialize-instance some-class :direct-superclasses (add-my-superclass (class-direct-superclasses some-class)))) 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/
First
|
Prev
|
Pages: 1 2 3 4 5 Prev: Is Scheme/LISP faster than C/C++ Next: Emacs language (was: line-move-visual) |