From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: GOOPS:Can I just overload "slot-set!" under #:virtual and let alone "slot-ref" ? Date: Thu, 2 Dec 2010 17:40:52 +0000 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=00163630f77d514ab2049670ec72 X-Trace: dough.gmane.org 1291312479 8730 80.91.229.12 (2 Dec 2010 17:54:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Dec 2010 17:54:39 +0000 (UTC) Cc: guile-user@gnu.org To: Nala Ginrut Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Dec 02 18:54:35 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PODMX-0000ez-RS for guile-user@m.gmane.org; Thu, 02 Dec 2010 18:54:34 +0100 Original-Received: from localhost ([127.0.0.1]:34898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PODMX-0003bE-1E for guile-user@m.gmane.org; Thu, 02 Dec 2010 12:54:33 -0500 Original-Received: from [140.186.70.92] (port=41979 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POD9K-0006WT-Gh for guile-user@gnu.org; Thu, 02 Dec 2010 12:40:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POD9J-0008A2-1y for guile-user@gnu.org; Thu, 02 Dec 2010 12:40:54 -0500 Original-Received: from mail-qy0-f169.google.com ([209.85.216.169]:57434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POD9I-00088U-Ux for guile-user@gnu.org; Thu, 02 Dec 2010 12:40:52 -0500 Original-Received: by qyk7 with SMTP id 7so4068000qyk.0 for ; Thu, 02 Dec 2010 09:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=xNF1311QqinxhgJjqk/P1lx3DVEeEnoFqfp+8QCArtM=; b=KKQFsrPcAgW0iuFHaqfqglWm5m2zXrj+jVaPNUeS/LcBKukZ0XJ/y8vIIEJ4YZYCnP 1HG6Kv+q4brcrUGxbs4s5Hsazn4NBSOk+sfsCaKrrhMMPhqco1v+NSsCW0wDPx0gzkBy dCkXuCqb9y54X4bKplRHcsrygqyvkJAn/JNZs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=aKVWhcq+ng8ETMb5T19LC8XVvdZVFhXGjhMty0TjTMCFH9V3SWs12+eUza6J0oJrUT MSfyq9kLvHk0yRRwv9MhZsopg2CdNw+ECMFtK5manY3aiO+oW9hZISm8rzHBfiw/I0b0 EixcuEeqkMG4YDeUUV/gDYvgn5fFEkVUY1My4= Original-Received: by 10.229.250.135 with SMTP id mo7mr251019qcb.220.1291311652096; Thu, 02 Dec 2010 09:40:52 -0800 (PST) Original-Received: by 10.229.225.198 with HTTP; Thu, 2 Dec 2010 09:40:52 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Mailman-Approved-At: Thu, 02 Dec 2010 12:52:55 -0500 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8280 Archived-At: --00163630f77d514ab2049670ec72 Content-Type: text/plain; charset=ISO-8859-1 On 2 December 2010 07:06, Nala Ginrut wrote: > Hi, everybody! > I got a question while I'm trying GOOPS, here is some example code pieces: > ;;guile code > (define-class () > (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! > I'm not sure this is what you mean... but yes, your #:slot-ref lambda can do a slot-ref on normal slots, such as "cache", e.g.: #:slot-ref (lambda (o) (car (slot-ref o 'cache))) Neil --00163630f77d514ab2049670ec72 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I'm not sure this is what you mean... but yes, y= our #:slot-ref lambda can do a slot-ref on normal slots, such as "cach= e", e.g.:

=A0=A0 #:slot-ref (lambda (o) (car (slot-ref o 'c= ache)))

Neil
--00163630f77d514ab2049670ec72--