[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
obscure problem
From: |
David Pirotte |
Subject: |
obscure problem |
Date: |
Sun, 03 Jun 2001 20:57:18 +0200 |
Hello,
given the following defs:
(define (db-utils/build-db-class-slots table-attrs)
(let ((slots '(db-oid))
(slot-defs '((db-oid #:accessor db-oid
#:init-keyword #:db-oid
#:init-value #f))))
(for-each (lambda (table-attr)
(let* ((attr-name (cadr table-attr))
(slot (string->symbol attr-name))
(slot-kw (symbol->keyword slot)))
(set! slots (cons slot slots))
(set! slot-defs (cons `(,slot #:accessor ,slot
#:init-keyword ,slot-kw
#:init-value #f)
slot-defs))))
table-attrs)
(values (reverse! slots)
(reverse! slot-defs))
))
(define attrs '(("1" "reference" "text") ("2" "nom" "text") ("3" "zone" "text")
("4" "pos_x" "int4") ("5" "pos_y" "int4") ("6"
"ref_projet" "text") ("7" "img_nb" "int2")))
I can not point out why the first call does produce the expected result:
guile> (db-utils/build-db-class-slots attrs)
#<values values: ((db-oid reference nom zone pos_x pos_y ref_projet img_nb)
((db-oid #:accessor db-oid #:init-keyword #:db-oid
#:init-value #f) (reference #:accessor reference #:init-keyword #:reference
#:init-value #f) (nom #:accessor nom #:init-keyword
#:nom #:init-value #f) (zone #:accessor zone #:init-keyword #:zone #:init-value
#f) (pos_x #:accessor pos_x #:init-keyword #:pos_x
#:init-value #f) (pos_y #:accessor pos_y #:init-keyword #:pos_y #:init-value
#f) (ref_projet #:accessor ref_projet #:init-keyword
#:ref_projet #:init-value #f) (img_nb #:accessor img_nb #:init-keyword #:img_nb
#:init-value #f)))>
guile>
BUT, the second and subsequent calls not: (just to make sure that attrs
remained as defined at first)
guile> attrs
(("1" "reference" "text") ("2" "nom" "text") ("3" "zone" "text") ("4" "pos_x"
"int4") ("5" "pos_y" "int4") ("6" "ref_projet" "text")
("7" "img_nb" "int2"))
guile>
guile> (db-utils/build-db-class-slots attrs)
#<values values: ((img_nb ref_projet pos_y pos_x zone nom reference db-oid
reference nom zone pos_x pos_y ref_projet img_nb)
((img_nb #:accessor img_nb #:init-keyword #:img_nb #:init-value #f) (ref_projet
#:accessor ref_projet #:init-keyword #:ref_projet
#:init-value #f) (pos_y #:accessor pos_y #:init-keyword #:pos_y #:init-value
#f) (pos_x #:accessor pos_x #:init-keyword #:pos_x
#:init-value #f) (zone #:accessor zone #:init-keyword #:zone #:init-value #f)
(nom #:accessor nom #:init-keyword #:nom #:init-value
#f) (reference #:accessor reference #:init-keyword #:reference #:init-value #f)
(db-oid #:accessor db-oid #:init-keyword #:db-oid
#:init-value #f) (reference #:accessor reference #:init-keyword #:reference
#:init-value #f) (nom #:accessor nom #:init-keyword
#:nom #:init-value #f) (zone #:accessor zone #:init-keyword #:zone #:init-value
#f) (pos_x #:accessor pos_x #:init-keyword #:pos_x
#:init-value #f) (pos_y #:accessor pos_y #:init-keyword #:pos_y #:init-value
#f) (ref_projet #:accessor ref_projet #:init-keyword
#:ref_projet #:init-value #f) (img_nb #:accessor img_nb #:init-keyword #:img_nb
#:init-value #f)))>
guile>
??? further calls would always produce the latest results, doubling
HOWEVER, if I change both calls to 'reverse!' and use 'reverse' instead, it
does work,
is this the expected behavior?
thanks
david
- obscure problem,
David Pirotte <=