dynamic-features.scm 19.8 KB
Newer Older
1 2
(define-module (logic guile-log dynamic-features)
  #:use-module (logic guile-log)
3 4
  #:use-module (logic guile-log vlist)
  #:use-module (logic guile-log functional-database)
5 6 7 8 9 10 11 12 13 14 15 16 17
  #:use-module (logic guile-log umatch)
  #:export(add-dynamic-object-features
	   ;; general way of binding a dynamic-object api
	   add-dynamic-object-features
	   
	   ;; more specific way of binding dynamic object api
	   add-fluid-dynamics             ;; e.g. a wraped functional 
	                                  ;; datastructure
	   add-vlist-dynamics
	   add-vhash-dynamics
	   add-dynamic-function-dynamics
	   add-dynamic-barrier

18 19 20
           mk-combine-dynamics 
           ;; this can combine many dynamics into one dynamic
           
21 22 23 24 25 26 27 28
	   ;; more specific way of binding dynamic object api
	   make-fluid-dynamics             ;; e.g. a wraped functional 
	                                  ;; datastructure
	   make-vlist-dynamics
	   make-vhash-dynamics
	   make-dynamic-function-dynamics
	   make-dynamic-barrier

29 30 31 32 33 34
	   ;; to enable a dynamic object feature from this point and up the 
	   ;; stack (h #:optional fail)
	   backtrack-dynamic-object
	   not-backtrack-dynamic-object
	   fluid-guard-dynamic-object
	   state-guard-dynamic-object
35
	   state-guard-dynamic-object-zip
36 37 38 39 40
	   always-state-guard-dynamic-object 

	   ;; to execute code with a dynamic object feature
	   ;; (h thunk #:optional fail)
	   with-fluid-guard-dynamic-object
41
	   with-fluid-guard-dynamic-object-once
42
	   with-state-guard-dynamic-object
43
	   with-state-guard-dynamic-object-zip
44 45
	   with-always-state-guard-dynamic-object 
	   with-backtrack-dynamic-object
46
	   with-backtrack-dynamic-object-once
47 48
	   with-not-backtrack-dynamic-object

49 50
           copy-dynamic-object
           set-dynamic
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
	   ))

;; This will enable good behavior of e.g. default of
;; * prolog_flags            - pure-dynamic
;; * operator table          - pure-dynamic
;; * char translator table   - pure-dynamic
;; * dynamic functions       - raw

#|
For functional datastructures that is typically wraped inside a fluid for thread
safeness, a special kind of mutataing datastructure can be constructed. For 
these datastructures guile-log can maintain the state eg. the functional data
structure in such a way that restorage of information is done magically. 

There is a simple constructor to use with well behaving datastructures like 
numbers lists etc, but for specially optimized datastructures care need to be 
taken to truncate e,g, reuse a datastructure only if it is safe to truncate 
and also guard a state for a mutating truncation in case a state is stored.
Because these extra functions is not generic a more general association of the
api is needed to the functional object. With this tool one can manage the state
via accessors like ref,set,copy,mk etc. if these accessors are the only one 
used it is then a safe journey.
|#

(define *dynamic-trackers* (make-weak-key-hash-table))
(define (get-dynamic-api h) (hash-ref *dynamic-trackers* h))
(define itag   0)
(define iref   1)
(define iset   2)
(define i++    3)
(define itrunc 4)
(define imk    5)
(define ibt    6)
84
(define itr    7)
85

86
(define (get d i)   (vector-ref d i))
87
(define (set d i b) (vector-set! d i b))
88
(define (params->id x) (x params->id))
89 90 91 92 93

(define (failadd s p cc h tag)
  (error (format #f "could not add dynamic features, ~a is not a ~a"
		 h tag)))

94 95
(define* (add-dynamic-object-features s p cc h tp? tp dref dset d++ dtrunc mk
				      #:key
96 97 98 99 100 101
				      (bt   #f)
				      (rd   #f)
				      (fail failadd))
  (if (tp? h)
      (begin
	(hash-set! *dynamic-trackers* h 
102
		   (vector tp dref dset d++ dtrunc mk bt rd))
103 104 105
	(cc s p))
      (fail s p cc h tp)))

106 107 108 109 110 111 112 113 114 115 116 117 118 119
(define (failadd-0 tag)
  (error (format #f "Could not add fluid dynamics on ~a" tag)))

(define* (make-dynamic-object-features h tp? tp dref dset d++ dtrunc mk
				       #:key
				       (bt   #f)
				       (rd   #f)
				       (fail failadd-0))
  (if (tp? h)
      (hash-set! *dynamic-trackers* h 
		 (vector tp dref dset d++ dtrunc mk bt rd))
      (fail h)))


120 121
(define dynamic-fluid? fluid?)
(define dynamic-vhash? (lambda (h) (and (fluid? h) (let ((h (fluid-ref h)))
122 123 124 125
						     (or
						      (not h)
						      (eq? h vlist-null)
						      (vhash? h))))))
126

127
(define* (make-dynamic-function env #:optional (name #f))
128 129
  (let* ((g    #f)
	 (name (if name
130 131 132 133 134
                   name
                   (gensym "dynfkn")))
         (r (mk-dyn name (lambda (f) (set! g f)))))
    (dynamic-env-set! g env)
    g))
135 136

(define (mkf str)
137
  (lambda h 
138
    (error (format #t "~a-dynamics association failed on element ~a" str h))))
139

Stefan Israelsson Tampe's avatar
Stefan Israelsson Tampe committed
140
(define nop (lambda x (if #f #f)))
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
(define* (mk-combine-dynamics s p cc . l)
  (let ((data (map (lambda (h) 	(hash-ref *dynamic-trackers* h))
                   l)))
    (add-dynamic-object-features s p cc data
               (lambda (x) #t)
               (map (lambda (d) (vector-ref d 0)) data)
               (lambda (l)
                 (map (lambda (d x) ((vector-ref d 1) x))
                      data l))
               (lambda (h v)
                 (map (lambda (d h v)
                        ((vector-ref d 2) h v))
                      data h v))
               (lambda (h)
                 (for-each 
                  (lambda (d h) ((vector-ref d 3) h))
                  data h))
               (lambda (h)
                 (for-each 
                  (lambda (d h) ((vector-ref d 4) h))
                  data h))
               (lambda (vs)
                 (map (lambda (d v)
                        ((vector-ref d 5) v))
                      data vs)))
    l))

168 169
(define* (add-fluid-dynamics s p cc h #:optional (fail (mkf 'fluid)))
  (add-dynamic-object-features s p cc h 
170 171 172 173 174 175 176 177
			       dynamic-fluid?
			       'fluid-dynamics
			       fluid-ref
			       fluid-set!
			       nop
			       nop
			       make-fluid
			       #:fail fail))
178

179 180 181
(define* (add-parameter-dynamics s p cc h const #:optional 
                                 (fail (mkf 'parameter)))
  (add-dynamic-object-features s p cc h 
182 183 184 185 186 187 188 189
			       procedure?
			       'parameter-dynamics
			       (lambda (f) (f))
			       (lambda (f v) (f v))
			       nop
			       nop
			       const 
			       #:fail fail))
190

191 192
(define* (add-vhash-dynamics s p cc h #:optional (fail (mkf 'vhash)))
  (add-dynamic-object-features s p cc h 
193 194 195 196 197
			       dynamic-vhash?
			       'vhash
			       fluid-ref
			       fluid-set!
			       vlist-refcount++
198 199 200 201
			       (lambda (x y) 
				 (if (fluid? x)
				     (vhash-truncate! (fluid-ref x))
				     (vhash-truncate! x)))
202 203 204
			       make-fluid
			       #:fail fail))

205 206
(define* (add-vlist-dynamics s p cc h #:optional (fail (mkf 'vlist)))
  (add-dynamic-object-features s p cc h 
207 208 209 210 211
			       dynamic-vhash?
			       'vhash
			       fluid-ref
			       fluid-set!
			       vlist-refcount++
212 213 214 215
			       (lambda (x y) 
				 (if (fluid? x)
				     (vlist-truncate! (fluid-ref x))
				     (vlist-truncate! x)))
216 217 218
			       make-fluid
			       #:fail fail))

219 220 221
(define fdyn (mkf 'dynamic-function))
(define* (add-dynamic-function-dynamics s p cc h #:optional (fail fdyn))
  (add-dynamic-object-features s p cc h 
222 223 224 225 226 227 228 229
			       dynamic?
			       'dynamic-function
			       dynamic-env-ref
			       dynamic-env-set!
			       dynamic-refcount++
			       dynamic-truncate!
			       make-dynamic-function
			       #:fail fail))
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286

(define* (make-fluid-dynamics h #:optional (fail (mkf 'fluid)))
  (make-dynamic-object-features h 
			       dynamic-fluid?
			       'fluid-dynamics
			       fluid-ref
			       fluid-set!
			       nop
			       nop
			       make-fluid
			       #:fail fail))

(define* (make-parameter-dynamics h const #:optional 
                                 (fail (mkf 'parameter)))
  (make-dynamic-object-features h 
			       procedure?
			       'parameter-dynamics
			       (lambda (f) (f))
			       (lambda (f v) (f v))
			       nop
			       nop
			       const 
			       #:fail fail))

(define* (make-vhash-dynamics h #:optional (fail (mkf 'vhash)))
  (make-dynamic-object-features h 
			       dynamic-vhash?
			       'vhash
			       fluid-ref
			       fluid-set!
			       vlist-refcount++
			       vhash-truncate!
			       make-fluid
			       #:fail fail))

(define* (make-vlist-dynamics h #:optional (fail (mkf 'vlist)))
  (make-dynamic-object-features h 
			       dynamic-vhash?
			       'vhash
			       fluid-ref
			       fluid-set!
			       vlist-refcount++
			       vlist-truncate!
			       make-fluid
			       #:fail fail))

(define fdyn (mkf 'dynamic-function))
(define* (make-dynamic-function-dynamics h #:optional (fail fdyn))
  (make-dynamic-object-features h 
			       dynamic?
			       'dynamic-function
			       dynamic-env-ref
			       dynamic-env-set!
			       dynamic-refcount++
			       dynamic-truncate!
			       make-dynamic-function
			       #:fail fail))
287 288 289 290 291 292 293
      
;;This will make sure that we will backtrack in all future
(define (dfail tag)
  (lambda (s p cc h)
    (error (format #f "could not perform ~a dynamic feature for ~a"
		   h tag))))

294 295
(define (mk api e h ref tr?)
  (let ((bt (get api (if tr? itr ibt))))
296 297 298 299
    (if bt
	bt
	(let* ((aset (get api iset))
	       (++   (get api i++))	
300
	       (tr   (get api itrunc))
301
	       (bt   (case-lambda
302 303 304
                       (() 
                        (let ((ret (ref h)))
                          (when (and tr? (not (eq? e ret)))
305
                            (++ ret))
306
                          ret))
307
		     
308 309 310
                       ((x)
                        (if (eq? x params->id) 
                            h
311
                            (let ((xold (ref h)))
312
                              (aset h x)
313 314
                              (when (not (eq? x e)) (tr h xold))
			      (if #f #f)))))))
315 316 317
          (set api (if tr? itr ibt) bt)
          bt))))

318
(define (backtrack-ref h s)
319 320 321 322 323 324 325 326 327 328
  (let ((l.a (fluid-ref *unwind-parameters*)))
    (if (pair? l.a)
        (let lp ((l (car l.a)))
          (if (pair? l)
              (if (eq? (params->id (car l)) h)
                  (car l)
                  (lp (cdr l)))
              #f))
        #f)))

329
(define (backtrack-add f s)
330
  (let ((l.a (fluid-ref *unwind-parameters*)))
331
    (gp-fluid-set! *unwind-parameters*
332 333 334 335
      (if (pair? l.a)
          (cons (cons f (car l.a)) (cdr l.a))
          (cons (cons f '()) '())))))

336 337
(define (backtrack-remove h s)
  (gp-fluid-set! *unwind-parameters*
338 339 340 341 342 343 344 345 346 347 348 349 350
    (let ((l.a (fluid-ref *unwind-parameters*)))
      (if (pair? l.a)
          (let ((l (let lp ((l (car l.a)))
                     (if (pair? l)
                         (if (eq? (params->id (car l)) h)
                             (cdr l)
                             (cons (car l) (lp (cdr l))))))))
            (if (pair? l)
                (cons l (cdr l.a))
                '()))
          '()))))


351 352 353 354
(define-syntax-rule (dotr) #t)	  
(define-syntax-rule (dobt) #f)	  

(define* (backtrack-dynamic-object s p cc h 
355
				   #:optional (fail (dfail 'backtrack)))
356 357 358 359 360
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
361
	       (bt  (mk api e h ref (dobt))))
362
	  (when (not (backtrack-ref h s))
363
		(backtrack-add bt s))
364 365 366 367 368 369 370 371 372
	  (cc s p)))))


(define* (not-backtrack-dynamic-object s p cc h 
				       #:optional (fail (dfail 'not-backtrack)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(begin
373 374
	  (when (backtrack-ref h s)
		(backtrack-remove h s))
375 376 377 378 379 380 381
	  (cc s p)))))

#|
if the system backtracks over this barrier the old value will be reinstated
else if the control reenter it will install the value it had when backtracking
before. This works very much like a fluid
|#
Stefan Israelsson Tampe's avatar
Stefan Israelsson Tampe committed
382
(define* (fluid-guard-dynamic-object s p cc h 
383 384 385 386 387 388
				    #:optional (fail (dfail 'fluid-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
389
	       (bt  (mk api e h ref (dobt))))
Stefan Israelsson Tampe's avatar
Stefan Israelsson Tampe committed
390 391
	  (gp-fluid-set bt e)
          (cc s p)))))
392 393 394 395 396 397 398 399 400 401 402 403 404

;; This will make sure that h is dynamic below the boundary
;; e.g. does not get store and restored after this boundary aif a store and
;; a restore is done afterwards unless another guard is issued.
;; else if if the store / restore is between it will be stored and restored
;; guarranteed.
(define* (state-guard-dynamic-object s p cc h
				     #:optional (fail (dfail 'state-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
405
	       (rd  (mk api e h ref (dotr))))
406

407
          (let ((wind (gp-windlevel-ref s)))
Stefan Israelsson Tampe's avatar
Stefan Israelsson Tampe committed
408
            (gp-undo-safe-variable-lguard
Stefan Israelsson Tampe's avatar
Stefan Israelsson Tampe committed
409
             rd
410 411 412
             (gp-rebased-level-ref wind) 
             s)
            (cc s p))))))
413

414 415 416 417 418 419 420 421
(define* (state-guard-dynamic-object-zip 
          s p cc h #:optional (fail (dfail 'state-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
	       (rd  (mk api e h ref (dotr))))
422

423 424
	 (let ((wind (gp-windlevel-ref s)))
           (gp-undo-safe-variable-lguard 
Stefan Israelsson Tampe's avatar
Stefan Israelsson Tampe committed
425
            rd
426 427 428
            (gp-rebased-level-ref (- wind 1))
            s)
           (cc s p))))))
429 430 431 432 433 434 435 436 437 438 439 440

;; This will make sure to always redo to the old value when restoring a state
;; This will override any usages of guard boundary
;; This will be active for all future execution.
(define* (always-state-guard-dynamic-object 
	  s p cc h 
	  #:optional (fail (dfail 'always-state-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
441
	       (rd  (mk api e h ref (dotr))))
Stefan Israelsson Tampe's avatar
Stefan Israelsson Tampe committed
442
	  (gp-undo-safe-variable-lguard rd #t s)
443 444
	  (cc s p)))))

445

446 447 448 449 450 451 452 453 454 455 456 457 458 459
;;
;;
;;    -------------------- W I T H -------------------
;;
;;
(define* (with-fluid-guard-dynamic-object 
	  s p cc h code 
	  #:optional (fail (dfail 'with-fluid-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
	       (++  (get api i++))
460
	       (bt  (mk api e h ref (dobt))))
461 462 463
	  (gp-fluid-set bt e)
	  (code s p 
	     (lambda (s p)
464 465 466 467 468
               (let ((d (ref h)))
                 (when (not (eq? e d))
                   (++ d))
                 (gp-fluid-set bt e)
                 (cc s p))))))))
469

470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
(define* (with-fluid-guard-dynamic-object-once
	  s p cc h code 
	  #:optional (fail (dfail 'with-fluid-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
	       (bt  (mk api e h ref (dobt))))
	  (gp-fluid-set bt e)
	  (code s p 
	     (lambda (s pp)
	       (gp-fluid-set bt e)
	       (cc s p)))))))

485 486 487
(define* (with-backtrack-dynamic-object 
	  s p cc h code 
	  #:optional (fail (dfail 'with-backtrack)))
488
  (let* ((api   (get-dynamic-api h))
489
         (old   (backtrack-ref h s)))
490
    (if (not api) 
491 492 493 494 495 496 497 498 499 500 501
        (fail s p cc h)	
	(let* ((ref (get api iref))
	       (e   (ref h))
	       (bt (mk api e h ref (dobt))))
	  (backtrack-add bt s)
	  (gp-fluid-set bt e)
	  (code s p
		(lambda (s p)
		  (gp-fluid-set bt e)
		  (backtrack-remove h s)
		  (cc s p)))))))
502

503 504 505 506 507

(define* (with-backtrack-dynamic-object-once 
	  s p cc h code 
	  #:optional (fail (dfail 'with-backtrack)))
  (let* ((api   (get-dynamic-api h))
508
         (old   (backtrack-ref h s)))
509 510
    (if (not api) 
        (fail s p cc h)
511 512 513 514 515 516 517 518 519 520 521
	(let* ((ref (get api iref))
	       (e   (ref h))
	       (bt (mk api e h ref (dobt))))
	  (backtrack-add bt s)
	  (gp-fluid-set bt e)
	  (let ((old-bt (bt)))
	    (code s p
		  (lambda (s pp)
		    (backtrack-remove h s)		       
		    (gp-fluid-set bt e)
		    (cc s p))))))))
522 523


524 525 526
(define* (with-not-backtrack-dynamic-object 
	  s p cc h code 
	  #:optional (fail (dfail 'with-not-backtrack)))
527
  (let* ((api   (get-dynamic-api h))
528
         (old   (backtrack-ref h s)))
529 530 531
    (if (not api) 
        (fail s p cc h)
        (when old
532
          (backtrack-remove h s)
533
          (code s p
534
		(lambda (s p)
535
		  (backtrack-add old s)
536 537 538 539 540 541 542 543 544 545 546
		  (cc s p)))))))

;; The same as above but guard it only inside code
(define* (with-state-guard-dynamic-object
	  s p cc h code
	  #:optional (fail (dfail 'with-state-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
	       (rd  (mk api e h ref (dotr))))
	  (let ((wind (gp-windlevel-ref s)))
            (let ((w  (gp-rebased-level-ref wind)))
              (gp-undo-safe-variable-lguard rd w  s)
              (code s p 
                    (lambda (s p)
                      (gp-undo-safe-variable-rguard rd w s)
                      (cc s p)))))))))

(define* (with-state-guard-dynamic-object-zip
	  s p cc h code
	  #:optional (fail (dfail 'with-state-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
	       (rd  (mk api e h ref (dotr))))
	  (let ((wind (gp-windlevel-ref s)))
            (let ((w  (gp-rebased-level-ref (- wind 1))))
              (gp-undo-safe-variable-lguard rd w  s)
              (code s p 
                    (lambda (s p)
                      (gp-undo-safe-variable-rguard rd w s)
                      (cc s p)))))))))
572 573 574 575 576 577 578 579 580 581

;; The limited scope to code variant
(define* (with-always-state-guard-dynamic-object 
	  s p cc h code 
	  #:optional (fail (dfail 'with-always-state-guard)))
  (let ((api (get-dynamic-api h)))
    (if (not api) 
	(fail s p cc h)
	(let* ((ref (get api iref))
	       (e   (ref h))
582
	       (rd  (mk api e h ref (dotr))))
583 584 585 586 587 588 589
	  (gp-undo-safe-variable-lguard rd #t  s)
	  (code s p 
		(lambda (s p)
		  (gp-undo-safe-variable-rguard rd #t s)
		  (cc s p)))))))

(define* (copy-dynamic-object
590
	  s p cc x y #:key (name #f) (fail (dfail 'copy)))
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605
  (let ((x (gp-lookup x s))
        (y (gp-lookup y s)))
    (let ((api (get-dynamic-api x)))
      (if (not api) 
          (fail s p cc x)	
          (let* ((++  (get api i++))
                 (mk  (get api imk))
                 (ref (get api iref))
                 (h   (if name 
                          (mk (ref x) #:name name)
                          (mk (ref x)))))
            ((<lambda> () 
	       (<=> y h)
               (<code> (++ (ref x))))
             s p cc))))))
606

607 608
(<define> (failsetxy s p cc x y tx ty)
  (error (format #f "not similar objects (set ~a:~a ~a:~a)"
609 610 611
		 x tx y ty)))
  
(define* (set-dynamic  
612
	  s p cc x y #:key (fail (dfail 'set)) (failxy failsetxy))
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
  (let ((x (gp-lookup x s))
        (y (gp-lookup y s)))
    (let ((api-x (get-dynamic-api x)))
      (if (not api-x) 
          (fail s p cc x)	
          (let ((api-y (get-dynamic-api y)))
            (if (not api-y) 
                (fail s p cc y)	
                (let ((tag-x (get api-x itag))
                      (tag-y (get api-y itag)))
                  (if (eq? tag-x tag-y)
                      (let ((set  (get api-x iset))
                            (ref  (get api-y iref))
                            (++   (get api-y i++)))
                        (set x (ref y))
                        (++ (ref y))
                        (cc s p))
                      (failxy s p cc x y tag-x tag-y)))))))))
631 632 633 634 635
  
;; Use this to debug vhash behavior
(define (analyze pred x)
  (if (and (vlist? x) pred)
      (let ((a (struct-ref x 0))
636 637 638 639 640 641 642 643 644 645
            (b (struct-ref x 1)))
        (format #t "<vhash> offset = ~a, " b)
        (let ((block (vector-ref a 0))
              (off   (vector-ref a 2))
              (size  (vector-ref a 3))
              (free  (vector-ref a 4)))
          (format #t " size ~a, free ~a~%" size free)
          (let lp ((i b))
            (if (>= i 0)
                (let* ((next (number->string
646 647 648
				(logand #xffffffff 
					(vector-ref block (+ (* size 3) i)))
				16))
649 650 651 652 653
                       (back (ash
                              (vector-ref block (+ (* size 3) i))
                              -32))
                       (hash (vector-ref block (+ (* size 2) back)))
                       (v    (object-address (vector-ref block i)))) 
654
				      
655 656 657 658
                  (format #t "~a: next ~a, back ~a hashv ~a key ~a~%" 
                          i next back 
                          hash (number->string v 16))
                  (lp (- i 1))))))
659

660 661
        (format #t "<assoc>~%")))
  x)
662

663
      
664
(<wrap> add-fluid-dynamics *var-attributator*)