guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fluids for dynamic scoping


From: Viktor Pavlenko
Subject: fluids for dynamic scoping
Date: Tue, 8 Apr 2003 22:22:27 -0400

Hello,

I intend to use with-fluids to simplify a data structure creation (see
below). However, after reading some discussions in the mailing list
archives regarding inherent "incorrectness" of fluid-let, I now have
doubts if the following code is OK. Is there any way to achieve similar
behavior without fluids?

------------------------------------------------------------------>8
(use-modules (ice-9 optargs))

(define a-field-default (make-fluid))

(define (make-my-record . args)
  (let-keywords
   args #f (id name (a-field (fluid-ref a-field-default)))
   (list (cons "ID" id)
         (cons "NAME" name)
         (cons "A-FIELD" a-field))))

...
 (with-fluids ((a-field-default 'ABC))
              (list (make-my-record #:id 0
                                    #:name "zero")
                    (make-my-record #:id 1
                                    #:name "one")
                    (make-my-record #:id 2
                                    #:name "two")
                    ...
                    (make-my-record #:id 99
                                    #:name "special"
                                    #:a-field 'XYZ)))
...
------------------------------------------------------------------>8

Thank you in advance for any insight.

-- 
Viktor




reply via email to

[Prev in Thread] Current Thread [Next in Thread]