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

> 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

Thanks for your answer :-)
But I think a new kind of slot allocation seems not easy.
For example. If I got a class "player", and assume we've already defined
a new kind allocation, say, #:allocation #:private.
===============================
(define-class <player> ()
  ......
  (score #:init-value 0 #:allocation #:private)
  ......)
=====
I don't want somebody change "score" except calling a method to compute
his real score.
And I have a method to update player's score:
=====
(define-method (score-update (player <player>))
 ...
 (slot-set! (slot-ref player 'score) newscore)
 ... )
========================
The problem is how to check the scope of "score" from "score-update".
I've no idea because the definition of "score-update" is actually out of
the class definition. 

Can I get some advice about the topic "how to hide the critical
property"? Or maybe I have some misunderstandings?

-- 
GNU Powered it
GPL Protected it
GOD Blessed it

HFG - NalaGinrut




  reply	other threads:[~2011-03-09  9:27 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
2011-03-09  9:27   ` nalaginrut [this message]
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=1299662845.2577.82.camel@Renee-desktop \
    --to=nalaginrut@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=neil@ossau.uklinux.net \
    /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).