guile-user
[Top][All Lists]
Advanced

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

Re: Is there any approach to define "private" vars in GOOPS?


From: Neil Jerram
Subject: Re: Is there any approach to define "private" vars in GOOPS?
Date: Wed, 09 Mar 2011 08:46:49 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

nalaginrut <address@hidden> 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



reply via email to

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