From: Volkan YAZICI <yazicivo@ttnet.net.tr>
Cc: guile-user@gnu.org
Subject: Re: Restoration of Session Variables
Date: Sat, 21 Oct 2006 00:15:00 +0300 [thread overview]
Message-ID: <20061020211500.GD2076@alamut> (raw)
In-Reply-To: <877iyuzpab.fsf@ossau.uklinux.net>
On Oct 20 09:49, Neil Jerram wrote:
> Volkan YAZICI <yazicivo@ttnet.net.tr> writes:
> > I'm executing seperate procedures in the same Guile session initialized
> > by scm_init_guile(). Just after initialization, some global definitions
> > get loaded. While executing supplied procedures sequentially, I want to
> > restrict their access to some variables. Namely I want to set some
> > definitions as read-only. Is this possible?
> >
> > I tried playing with fluids and dynamic states but couldn't figure out a
> > solution. I'd be very appreciated to hear any kind of suggestion.
>
> Not sure I completely understand. Can you give an example of one of
> the globals that you want to be read-only, and of an eval that would
> try - and should fail - to change it?
I've solved my problem by using fluid-let. Yes, there's no fluid-let in
Guile, but we've define-syntax and make-fluid:
(define-syntax fluid-let
(syntax-rules ()
((fluid-let ((var1 val1)
(var2 val2)
...)
body1
body2
...)
(let ((var1 (make-fluid))
(var2 (make-fluid))
...)
(fluid-set! var1 val1)
(fluid-set! var2 val2)
...
(let ((var1 (fluid-ref var1))
(var2 (fluid-ref var2))
...)
body1
body2
...)))))
(define globally-editable #t)
(define protect-me #t)
(fluid-let ((protect-me protect-me))
(set! globally-editable #f)
(set! protect-me #f))
(display globally-editable)(newline)
#f
(display protect-me)(newline)
#t
As you can see, we protected the value of protect-me even it looks to
the fluid-let scope that it modified protect-me.
Regards.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
prev parent reply other threads:[~2006-10-20 21:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-14 21:09 Restoration of Session Variables Volkan YAZICI
2006-10-20 20:49 ` Neil Jerram
2006-10-20 21:15 ` Volkan YAZICI [this message]
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=20061020211500.GD2076@alamut \
--to=yazicivo@ttnet.net.tr \
--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).