unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neil@ossau.uklinux.net>
To: NalaGinrut@gmail.com
Cc: Guile <guile-user@gnu.org>
Subject: Re: Is there any approach to define "private" vars in GOOPS?
Date: Wed, 09 Mar 2011 08:46:49 +0000	[thread overview]
Message-ID: <87d3m0llza.fsf@ossau.uklinux.net> (raw)
In-Reply-To: <1299638259.2577.5.camel@Renee-desktop> (nalaginrut@gmail.com's message of "Wed, 09 Mar 2011 10:37:39 +0800")

nalaginrut <nalaginrut@gmail.com> 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	other threads:[~2011-03-09  8:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-09  2:37 Is there any approach to define "private" vars in GOOPS? nalaginrut
2011-03-09  8:46 ` Neil Jerram [this message]
2011-03-09  9:27   ` nalaginrut
2011-03-09  9:37     ` nalaginrut
2011-03-09 22:19       ` Andy Wingo
2011-04-01 22:55       ` Neil Jerram
2011-03-09  9:46   ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d3m0llza.fsf@ossau.uklinux.net \
    --to=neil@ossau.uklinux.net \
    --cc=NalaGinrut@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).