From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Volkan YAZICI Newsgroups: gmane.lisp.guile.user Subject: Re: Restoration of Session Variables Date: Sat, 21 Oct 2006 00:15:00 +0300 Message-ID: <20061020211500.GD2076@alamut> References: <20061014210902.GB1317@alamut> <877iyuzpab.fsf@ossau.uklinux.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1161384105 17171 80.91.229.2 (20 Oct 2006 22:41:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 20 Oct 2006 22:41:45 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Oct 21 00:41:44 2006 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gb33b-0000oR-ME for guile-user@m.gmane.org; Sat, 21 Oct 2006 00:41:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gb33b-0008ON-5E for guile-user@m.gmane.org; Fri, 20 Oct 2006 18:41:39 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gb1jm-0003cz-Rh for guile-user@gnu.org; Fri, 20 Oct 2006 17:17:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gb1jk-0003bg-54 for guile-user@gnu.org; Fri, 20 Oct 2006 17:17:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gb1jj-0003bU-SU for guile-user@gnu.org; Fri, 20 Oct 2006 17:17:03 -0400 Original-Received: from [212.175.13.129] (helo=fep01.ttnet.net.tr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gb1jj-0003PU-HR for guile-user@gnu.org; Fri, 20 Oct 2006 17:17:03 -0400 Original-Received: from (unknown) by AVGW-I-1.ttnet.net.tr with smtp id 1185_51711ec0_6080_11db_9a09_001422175f0e; Sat, 21 Oct 2006 00:17:02 +0300 Original-Received: from alamut ([85.99.4.1]) by fep01.ttnet.net.tr with ESMTP id <20061020211656.NSO27706.fep01.ttnet.net.tr@alamut>; Sat, 21 Oct 2006 00:16:56 +0300 Original-Received: from (dsl.dynamic859941.ttnet.net.tr [85.99.4.1]) by AVGW-I-6.ttnet.net.tr with smtp id 4973_46bef934_6080_11db_8189_0011433771ac; Sat, 21 Oct 2006 00:16:52 +0300 Original-To: Neil Jerram Content-Disposition: inline In-Reply-To: <877iyuzpab.fsf@ossau.uklinux.net> User-Agent: Mutt/1.4.2.1i X-NAI-Spam-Rules: 1 Rules triggered BAYES_00=-2.5 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5618 Archived-At: On Oct 20 09:49, Neil Jerram wrote: > Volkan YAZICI 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