This is the mail archive of the guile@cygnus.com mailing list for the guile project.


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

Re: Problem setting value of symbol passed to function


Michael Bukin writes:

 > I have found solution which I can use while I have not learned enough
 > guile internals to make better one
 > 
 > (define (test s v)
 >   (if (not (symbol? s))
 >       (error "s must be symbol"))
 >   (if (not (integer? (eval s)))
 >       (error "s must evaluate to integer"))
 >   (let ((x (list 'set! s v)))
 >     (eval x)))
 > 
 > (define var 0)
 > var => 0
 > (test 'var 10)
 > var => 10

i misread "internals" as "infernals".  :->

here is another way:

(define (test s v)
  (and (symbol? s)
       (integer? v)
       (module-set! (current-module) s v)))

thi