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


Russ McManus <russell.mcmanus@gs.com> writes:

> (nobody) writes:
> 
> > I have tried to rewrite that code in Scheme (both scm5d0 and guile)
> > and failed.  I am a newbie in Scheme, so perhaps I'm missing
> > something obvious.
> 
> Can you post some code that doesn't work?  From the example you posted,
> I suspect that it is possible to do this with guile.

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

Now I will try to find more efficient ways to do that in C.

-- 
Michael Bukin