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



> I have found solution which I can use while I have not learned enough
> guile internals to make better one

Good.

> (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
> 
> Now I will try to find more efficient ways to do that in C.

Let me just say that you almost never need 'eval'.  If you see it in
your program, you're almost certainly doing something clumsy, and maybe
even wrong.

-russ

--
"It's like a love-hate relationship, without the love."
             -- Jamie Zawinski, consummate UNIX hater, on Linux