This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fluid-let fun


fluid-let isn't behaving like I'd expect.  The docs say that:

    The temporary bindings are only visible in the current thread, and
    its descendent threads.

but the descendent threads don't seem to get the correct bindings.  New
threads seem to get the "top-most" value, not the immediate parent
thread.  For example, this program should print "main thread thread" but
instead prints "main thread main":

    (define level 'main)

    (define (print-level)
      (format #t "level=~A~%" level))

    (print-level)
    (force
      (future
       (fluid-let ((level 'thread))
         (print-level)
         (force (future (print-level))))))


A testsuite patch is attached that exercises the problem.  Sorry, I
don't have a fix.

Thanks!

Regards,
Chris Dean

Index: testsuite/misc-test.scm
===================================================================
RCS file: /cvs/kawa/kawa/testsuite/misc-test.scm,v
retrieving revision 1.35
diff -u -r1.35 misc-test.scm
--- testsuite/misc-test.scm	3 Jun 2003 16:33:28 -0000	1.35
+++ testsuite/misc-test.scm	11 Jul 2003 07:38:37 -0000
@@ -1,4 +1,4 @@
-(test-init "Miscellaneous" 112)
+(test-init "Miscellaneous" 113)
 
 ;;; DSSSL spec example 11
 (test '(3 4 5 6) (lambda x x) 3 4 5 6)
@@ -500,3 +500,20 @@
      (fprintf out format value))))
 (test "[ 23]" test-printf "[%3d]" 23)
 (test "[3.50 ]" test-printf "[%-5.2f]" 3.5)
+
+
+(define fluid-stack '())
+(define fluid-let-test-level 'main)
+(define (push-fluid-let-test-level!)
+  (set! fluid-stack (cons fluid-let-test-level fluid-stack)))
+(define (test-fluid-let-levels)
+  (push-fluid-let-test-level!)
+  (force
+   (future
+    (fluid-let ((fluid-let-test-level 'thread))
+      (push-fluid-let-test-level!)
+      (force (future (push-fluid-let-test-level!))))))
+  fluid-stack)
+
+(test '(thread thread main) test-fluid-let-levels)
+


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]