[plt-scheme] ajax and plt

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Fri Jul 3 03:16:52 EDT 2009

> I'm curious -- is there any advantage for this over something like:
> (let ([msg "Hello world"])
>   @js{alert(@msg)})
> (Random example, since using `string-append' is even more boring in  
> this style.)

I didn't know you could set things up to switch between readers like  
that with such simple syntax. It could be really useful. I have  
contemplated an @-style syntax but I have lacked the PLT know-how to  
set it up and experiment.

One thought. An @-reader solution would benefit from being backed by  
an AST - when you unquote to Scheme code, you need to know whether the  
surrounding context is a statement/expression and so on to work out  
how to splice the fragments back together. For example:

     (javascript->string (js ,(+ 1 2)))          => "3;" ; semicolon  
after the unquote
     (javascript->string (js (+ ,(+ 1 2) 4))) => "3+4;" ; no semicolon  
after the unquote

The context can be inferred by the programmer in these examples, but  
we assemble fragments of JS from all over the shop so protection  
against typos is quite important.

-- Dave

Posted on the users mailing list.