guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GOOPS:Can I just overload "slot-set!" under #:virtual and let alone "slo


From: Nala Ginrut
Subject: GOOPS:Can I just overload "slot-set!" under #:virtual and let alone "slot-ref" ?
Date: Thu, 2 Dec 2010 15:06:17 +0800

Hi, everybody!
I got a question while I'm trying GOOPS, here is some example code pieces:
;;guile code
(define-class <test> ()
  (cache #:init-form 0)
  (tt #:init-form 1
      #:allocation #:virtual
      #:slot-set! (lambda (o v)
                       (slot-set! o 'cache
                                     (cons v (slot-ref o 'cache)))
                        );;end lambda
      #:slot-ref (lambda (o) #f)  ;; ***FIXME: can I use generic "slot-ref" without re-define here??
  ..........
;;guile code end
-----------------------------------------------

Please notice the line with "***FIXME" .I know that the "slot-set!" and "slot-ref" must be re-defined under "#:allocation #:virtual", but can I find some approach that just re-define one of them? Maybe I'll need a modified(with overload) "slot-set!", but I need a generic "slot-ref" in some circumstance. I don't know how to do. If I called "slot-ref" in the re-defination of "slot-ref", that would be recursively infinite.
How can I deal with this? Any help will be appreciated, thanks!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]