How to unquote in GIMP Scheme -


i never used other implementations gimp's script-fu, , quite new gimp's scheme, too. so, maybe i'm wrong. however, followings not work in script-fu console:

(define x 13) (define s 'x) ; or (define s `x) ,s => error: eval: unbound variable: unquote  

similarly

(unquote s) => error: eval: unbound variable: unquote  

it seems me, "," planned work unquote has not been implemented. if so, how can solve following problem?

(define x 13) (define y 7) ; define procedure swap x , y (define (swap)    (let ((t 0))     (set! t ,'x)     (set! x ,'y)     (set! y t)   ) ) 

this should run multiple times, (set! t x)... not work.

your swap function work as:

(define (swap)   (let ((t 0))     (set! t x)     (set! x y)     (set! y t))) 

because set! syntactic keyword evaluates arguments specially. first argument (t in first set! expression in swap above) not evaluated; rather used identify location. second argument (x) evaluated and, in case, returns value held in location referenced identifier (x).

the syntactic keyword define works similarly. first argument not evaluated; used create new location; second argument evaluated. so, example, unquote not needed use:

(define s x) 

if trying define s returns current value of x rather value bound x when s allocated, make s function:

(define (s) x) 

then expression (s) return whatever x bound to.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -