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

* Re: fluids for dynamic scoping
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Koeppe @ 2003-04-09  9:36 UTC (permalink / raw)
  Cc: guile-user

Viktor Pavlenko <vvp@rogers.com> writes:

> 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?

The use of fluids in your code (MAKE-FLUID, FLUID-REF, WITH-FLUIDS) is
perfectly fine.  

There has been discussion in the mailing list regarding FLUID-LET,
which (despite its name) has nothing to do with fluids (and which you
didn't use).  FLUID-LET tries to simulate dynamic scoping using
DYNAMIC-WIND and SET!, which fails in a multi-threaded environment.

-- 
Matthias Köppe -- http://www.math.uni-magdeburg.de/~mkoeppe


_______________________________________________
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

* Re: fluids for dynamic scoping
  2003-04-09  9:36 ` Matthias Koeppe
@ 2003-04-23 23:59   ` Viktor Pavlenko
  0 siblings, 0 replies; 3+ messages in thread
From: Viktor Pavlenko @ 2003-04-23 23:59 UTC (permalink / raw)
  Cc: guile-user

>>>>> "MK" == Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> writes:

    MK> There has been discussion in the mailing list regarding
    MK> FLUID-LET, which (despite its name) has nothing to do with
    MK> fluids (and which you didn't use).  FLUID-LET tries to
    MK> simulate dynamic scoping using DYNAMIC-WIND and SET!, which
    MK> fails in a multi-threaded environment.

Sorry to revive the dead horse but what is the healthy position on the
dynamic scoping in scheme (and guile in particular)? I've read
elsewhere that dynamic scoping in LISP started as a bug and was
denounced many times since as inappropriate.

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