* Restoration of Session Variables
@ 2006-10-14 21:09 Volkan YAZICI
2006-10-20 20:49 ` Neil Jerram
0 siblings, 1 reply; 3+ messages in thread
From: Volkan YAZICI @ 2006-10-14 21:09 UTC (permalink / raw)
Hi,
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.
Regards.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Restoration of Session Variables
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
0 siblings, 1 reply; 3+ messages in thread
From: Neil Jerram @ 2006-10-20 20:49 UTC (permalink / raw)
Cc: guile-user
Volkan YAZICI <yazicivo@ttnet.net.tr> writes:
> Hi,
>
> 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?
Regards,
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Restoration of Session Variables
2006-10-20 20:49 ` Neil Jerram
@ 2006-10-20 21:15 ` Volkan YAZICI
0 siblings, 0 replies; 3+ messages in thread
From: Volkan YAZICI @ 2006-10-20 21:15 UTC (permalink / raw)
Cc: guile-user
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-20 21:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).