I would like to use Parenscript with ABCL and am hoping for a GWT-like experience.
What is the best way to share code between client and server? - Do I use the Parenscript constructs on the server? Not having CLOS seems a shame. - How would one send objects between client and server? - As JSON? How would the conversion be performed?
Thanks!
Axel
What is the best way to share code between client and server?
In practice mostly through macros (http://common-lisp.net/project/parenscript/reference.html#section-macros) with defmacro+ps and import-macros-from-lisp. You can also keep around pieces of code that you would COMPILE (CL) and PS-COMPILE, but I've never actually had to do that in my projects.
- Do I use the Parenscript constructs on the server? Not having CLOS
seems a shame.
You need to hide any CL-but-not-PS functionality under macros. Red Daly's Suave project (http://common-lisp.net/project/suave/) includes a CLOS for Parenscript though.
- How would one send objects between client and server?
- As JSON? How would the conversion be performed?
JSON is easiest. There's a couple of CL JSON libraries (http://common-lisp.net/project/cl-json/ and http://marijn.haverbeke.nl/st-json/). You can use Parenscript for generating JSON, but since it mostly does "the wrong thing" when you just give it data, it's easier to put something together specific to your JSON schema (which IMO should be used as an interface instead of a dumb serialization format anyway) using SYMBOL-TO-JS-STRING.
Vladimir
Thanks!
Axel
-- Axel Rauschmayer
axel@rauschma.de http://www.pst.ifi.lmu.de/people/staff/rauschmayer/axel-rauschmayer/ http://2ality.blogspot.com/ http://hypergraphs.de/
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
- Do I use the Parenscript constructs on the server? Not having CLOS
seems a shame.
You need to hide any CL-but-not-PS functionality under macros. Red Daly's Suave project (http://common-lisp.net/project/suave/) includes a CLOS for Parenscript though.
The Suave sub-project PSOS does two things that I think should become part of Parenscript: - The same way of object-orientation works on the server and the client (in my experience, code overlap does happen, mainly in helper methods and the structure of the data). - Instances maintain the correct instance-of relationship when transferred between client and server.
But, it does seem to introduce generic functions which would go against the goal of Parenscript to produce code that is close to what one would hand-code in JavaScript. Instead, I would favor generic functions that are specialized on the first argument only and then translated to JavaScript's flavor of object-orientation (maybe with the addition of class-based inheritance; but that can be borrowed from jQuery or Dojo).
Does this make sense? I am applying the experiences I have had with GWT to Parenscript, but that might not be the way to go.
Axel
parenscript-devel@common-lisp.net