guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

eval question


From: David Pirotte
Subject: eval question
Date: Wed, 30 May 2001 12:59:02 +0200

Hello

i use the following functions to generate define-class forms sent
to eval:

        (define (db-utils/build-db-class-slots table-attrs)
          (let ((slots '())
                (class-attr '()))
            (for-each (lambda (table-attr)
                        (let* ((attr-name (cadr table-attr))
                               (slot (string->symbol attr-name))
                               (slot-kw (string->symbol (string-append "#:" 
attr-name))))
                          (set! slots (cons slot slots))
                          (set! class-attr (cons `(,slot #:accessor ,slot
                                                         #:init-keyword ,slot-kw
                                                         #:init-value #f)
                                                 class-attr))))
                      table-attrs)
            (values (reverse! slots)
                    (reverse! class-attr))
            ))
        
        (define (db-utils/build-db-class db-con tb-name)
          (let ((class-name (string->symbol (string-append "<" tb-name ">")))
                (tb-attrs (get-tb-attr-def db-con tb-name)))
            (call-with-values (lambda () (db-utils/build-db-class-slots 
tb-attrs))
                              (lambda (slot-acce slot-defs)
                                `(define-class ,class-name () ,@slot-defs))
                              )))

but it does not produce the expected results:
                        
        gtk> (db-utils/build-db-class db "chefs")
        (define-class <chefs> () (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))

        gtk> (eval (db-utils/build-db-class db "chefs"))
        ERROR: Unbound variable: #:reference
        gtk> 

however, copy-paste the define-class code printed by the repl in the listener 
and
hiting enter does it

[once it works, the aim is to call eval directly in db-utils/build-db-class
of course]

any suggestion?
thanks
david



reply via email to

[Prev in Thread] Current Thread [Next in Thread]