unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* fluids for dynamic scoping
@ 2003-04-09  2:22 Viktor Pavlenko
  2003-04-09  9:36 ` Matthias Koeppe
  0 siblings, 1 reply; 3+ messages in thread
From: Viktor Pavlenko @ 2003-04-09  2:22 UTC (permalink / raw)


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


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-04-23 23:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-09  2:22 fluids for dynamic scoping Viktor Pavlenko
2003-04-09  9:36 ` Matthias Koeppe
2003-04-23 23:59   ` Viktor Pavlenko

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).