scheme - LISP clause for and clause let ¿why?,making a programming language in racket using ragg -


i have long been trying find error, i'm doing programming language , have next code, using ragg, have syntax-object(resto ...) has bracket data, transform syntax-object datum:

   (let ([i (syntax->datum #'(resto ...))])            (display "content i:")             (display i)            (if (eq? (string->symbol "(})"))                (display "true")                (display "false")             )    ) 

and output is:

content: (}) false 

but if this

   (for ([i (syntax->datum #'(resto ...))])      (displayln "content:")      (displayln i)      (if (eq? (string->symbol "}"))            (display "true")            (display "false")      )    ) 

and output is:

content: } true 

my question: ¿why if of clause let false? ¿as can compare these 2 types , result true without for?

documentation functions:

syntax->datum

each piece of code doing different thing, i'll show how make each 1 work. first 1 uses let assign variable whole list returned syntax->datum, , afterwards compare against list (better use equal? testing equality, it's more general):

(let ([i (syntax->datum #'(|}|))]) ; `i` contains `(})`   (display "content i: ")   (displayln i)   (if (equal? '(|}|)) ; list single element, symbol `}`       (displayln "true")       (displayln "false"))) 

the second piece of code using for iterate on each element in list, until finds symbol }:

(for ([i (syntax->datum #'(|}|))]) ; `i` contains `}`   (display "content i: ")   (displayln i)   (if (equal? '|}|) ; symbol `}`       (displayln "true")       (displayln "false"))) 

as side note, have careful way you're going process curly brackets {} in language, they're interpreted normal parentheses () in racket , they'll tricky handle, notice how had escape them surrounding them vertical bars.