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: Is there any approach to define "private" vars in GOOPS? Date: Wed, 09 Mar 2011 08:46:49 +0000 Message-ID: <87d3m0llza.fsf@ossau.uklinux.net> References: <1299638259.2577.5.camel@Renee-desktop> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1299661320 26015 80.91.229.12 (9 Mar 2011 09:02:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Mar 2011 09:02:00 +0000 (UTC) Cc: Guile To: NalaGinrut@gmail.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Mar 09 10:01:55 2011 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 1PxFHC-0002Cs-OI for guile-user@m.gmane.org; Wed, 09 Mar 2011 10:01:51 +0100 Original-Received: from localhost ([127.0.0.1]:46137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PxF5o-0007K1-KX for guile-user@m.gmane.org; Wed, 09 Mar 2011 03:50:04 -0500 Original-Received: from [140.186.70.92] (port=44084 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PxF3O-0006Fh-Tv for guile-user@gnu.org; Wed, 09 Mar 2011 03:47:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PxF3N-0002WB-1z for guile-user@gnu.org; Wed, 09 Mar 2011 03:47:34 -0500 Original-Received: from mail3.uklinux.net ([80.84.72.33]:49839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PxF3M-0002Ig-Tb for guile-user@gnu.org; Wed, 09 Mar 2011 03:47:33 -0500 Original-Received: from arudy (unknown [78.145.20.116]) by mail3.uklinux.net (Postfix) with ESMTP id 2C1BA1F661D; Wed, 9 Mar 2011 08:46:50 +0000 (GMT) Original-Received: from neil-laptop (unknown [192.168.11.4]) by arudy (Postfix) with ESMTP id 92C243801E; Wed, 9 Mar 2011 08:46:49 +0000 (GMT) In-Reply-To: <1299638259.2577.5.camel@Renee-desktop> (nalaginrut@gmail.com's message of "Wed, 09 Mar 2011 10:37:39 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 80.84.72.33 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:8502 Archived-At: nalaginrut writes: > hi all! > I got a question. Is there any approach to define a "private" > vars/methods in the GOOPS? Or it's impossible? I didn't find any > "private" info in the GOOPS manual. Hi there! In Guile, the visibility of identifiers - including any functions you've defined to get and set GOOPS slots - is controlled by the module system, and is completely orthogonal to anything specific to GOOPS. However, the module system can't prevent any code from doing (slot-ref obj 'some-slot-that-should-be-private) once it has OBJ, and knows that OBJ has a slot named some-slot-that-should-be-private. (In effect because slot names live in a different namespace from that of identifiers, and which isn't connected to the module system.) If you can determine at runtime whether or not any given slot access is allowed - perhaps based on (current-module) - it should be possible to enforce this by defining a new kind of slot #:allocation and putting that runtime check in the #:slot-ref function. Regards, Neil