[plt-scheme] Syntax objects and strings (or "stupid infix tricks")
Is there a way to turn a string into a syntax object without calling read?
Something feels wrong with what i'm doing. {I mean someting feels wrong
beond the fact that i'm dealing with infix notation ;)}
The setup:
i've written a re-infixer that does the reverse of Dannys "infix" package.
It works as follows:
> (refix `(+ 2 4))
"(2 + 4)"
{note that it returned a string}
I then do a "full circle" test by doing:
> (refix `(define x 7))
"define(x, 7)"
> x
. reference to undefined identifier: x
> (read (open-input-string (string-append "(infix " (refix `(define x 7))
")")))
(infix define (x ,7))
> x
. reference to undefined identifier: x
> (eval (read (open-input-string (string-append "(infix " (refix `(define x
7)) ")"))))
#<primitive:>>
> x
7
However doing '(string-append "(infix " {blah} ")")' feels wrong. It feels
more like i should be doing:
(eval `(infix ,(some-command-to-turn-a-string-into-a-syntax-object
"define(x, 7)")))
Anyone have comments, or ideas for better ways to do this?
Corey
--
((lambda (y) (y y)) (lambda (y) (y y)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20061207/128aca7f/attachment.html>