Hi Jon,

> > You can also encode numbers, internal+external symbols, and simple
> > lists, if you use 'ht:Fmt' (or 'mkUrl').
> >
> >    : (pack "http://localhost:8080/@json?"; (ht:Fmt 123 'abc (4 5 6)))
> >    -> "http://localhost:8080/@json?+123&$abc&_+4_+5_+6";
> That's nice, but more useful when the request shall come from Pico Lisp.
> In my case, requests are coming from JavaScript in the browser. ;-)

This is also the case in the GUI. In fact, the whole interactivity of
"lib/form.js" depends on it.

The HTTP server does not know the difference whether a GET or POST
request originated directly from the Browser, from some JavaScript
XMLHttpRequest, or another picoLisp process. I wrote the above 'pack'
statement just as an example.

Stand-alone JavaScript, of course, cannot generate external objects
(prefixed by '-'), but it surely makes sense to be able to pass numbers
(prefixed by '+') and normal strings (without prefix). And in certain
applications (like the JavaScript RPC I just wrote) it turns out to be
very useful to be able to pass internal symbols (prefixed by '$') and
lists (elements prefixed by '_').

> It seems to me that it won't be easy to make use of the Pico Lisp URL
> encoding system when using jQuery AJAX calls like getJSON, as jQuery uses
> the more traditional key-value style (http://...?k1=v1&k2=v2...). Is there

No problem at all, I think. It is all there.

The arguments following the '?' in an URL are processed in such a way
that patterns of the form Variable=Value are executed as separate
assignments, and only the remaining values are passed as arguments. For
example, the URL

   http://[EMAIL PROTECTED]&*Var1=444&+abc&*Var2=def&xyz

will assign the number '444' to '*Var1' and the string "def" to '*Var2',
and then call 'foo' with three arguments (a number '123', an internal
symbol 'abc', and a string "xyz").

You must know, however, that for security reasons these assignments to
global variables will work only if the variable's names start with an
asterisk (in addition to the standard constraint that these variables
must be "allowed"). Other plain symbols (like 'k1' in your example) will
get the value ("v1") stored in the property 'http' instead of the value

- Alex

Reply via email to