<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Dear Chide,<br>
<br>
the JSON serialization works fine with ADTs. It simply represents
them as JSON arrays that contain a string as first element that
encodes the contstructor.<br>
The only limitations the library has are serialization of functions
(inside data structures) and inherently lazy structures.
Serialization is done strict, so serialization of infinite lists
isn't the best idea :)<br>
Serialization of functions is possible through some trickery with
dynamics, but that is kinda scary and crashes your program if you
deserialize after recompilation :)<br>
<br>
Best,<br>
Bas<br>
<br>
<br>
On 30-11-11 16:04, Groenouwe, C. wrote:
<blockquote
cite="mid:8F6DD0D591ECE64B859B081E73E2BEEF1C889949@PEXMB002B.vu.local"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
<div style="direction: ltr;font-family: Tahoma;color:
#000000;font-size: 10pt;">Dear Bas and Erik,<br>
<br>
Thanks for your good tips, I'll keep them in mind. However, I<br>
don't know to what extent it applies to my current situation. My<br>
first post was perhaps a bit misleading in that I have defined
some<br>
types which beautifully fit in algebraic data types. I.e. I'd
rather<br>
express the problem in the Clean type than in an OO structure
(btw, the<br>
other language I use is not java, it was just an hypothetical
example).<br>
I guess JSON is not expressive enough to deal with ADTs, or is
it?<br>
<br>
<div style="font-family: Times New Roman; color: rgb(0, 0, 0);
font-size: 16px;">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF345755"><font
color="#000000" face="Tahoma" size="2"><b>Van:</b>
<a class="moz-txt-link-abbreviated" href="mailto:clean-list-bounces@science.ru.nl">clean-list-bounces@science.ru.nl</a>
[<a class="moz-txt-link-abbreviated" href="mailto:clean-list-bounces@science.ru.nl">clean-list-bounces@science.ru.nl</a>] namens Bas Lijnse
[<a class="moz-txt-link-abbreviated" href="mailto:b.lijnse@cs.ru.nl">b.lijnse@cs.ru.nl</a>]<br>
<b>Verzonden:</b> maandag 21 november 2011 15:02<br>
<b>Aan:</b> <a class="moz-txt-link-abbreviated" href="mailto:clean-list@science.ru.nl">clean-list@science.ru.nl</a><br>
<b>Onderwerp:</b> Re: [clean-list] Dynamic typing for
communication with non-cleanprograms<br>
</font><br>
</div>
<div>The JSON libraries that Erik mentions are available from:<br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="https://svn.cs.ru.nl/repos/clean-platform/trunk/src/libraries/OS-Independent/Text/"
target="_blank">https://svn.cs.ru.nl/repos/clean-platform/trunk/src/libraries/OS-Independent/Text/</a><br>
<br>
I always use this when I want to do simple data exchange
between Clean and another language (I may be biased as
author/maintainer of the library though :) )<br>
<br>
Best,<br>
Bas<br>
<br>
On 21-11-11 14:52, <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:zuurb078@planet.nl" target="_blank">
zuurb078@planet.nl</a> wrote:
<blockquote type="cite">
<p><font size="2">And dump all the hard work on Java?
Dynamics are a proprietary Clean format and likely
more complex/liberal than you need. Maybe JSON is
easier to use: probably available in your JAVA
implementation already and under the hood JSON
converters are already available in Clean iTasks.<br>
<br>
<br>
-----Oorspronkelijk bericht-----<br>
Van: <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:clean-list-bounces@science.ru.nl"
target="_blank">
clean-list-bounces@science.ru.nl</a> namens
Groenouwe, C.<br>
Verzonden: ma 21-11-2011 13:39<br>
Aan: <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:pieter@cs.ru.nl" target="_blank">
pieter@cs.ru.nl</a><br>
CC: <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:clean-list@science.ru.nl"
target="_blank">
clean-list@science.ru.nl</a><br>
Onderwerp: [clean-list] Dynamic typing for
communication with non-cleanprograms<br>
<br>
Dear Pieter (and others),<br>
<br>
Then another question:<br>
<br>
If you want to send information from one programming
language (e.g. Java) to Clean, a typical way to go
would be the following. First define an intermediate
representation (for example in XML, or your own
format). Then write a generator on the sender's side
(in this case in Java), which converts a Java value or
object into a file in the intermediate representation.
Finally, write a parser on the receiver's side (Clean)
which parses file holding the intermediate
representation into a Clean value (with a Clean type).
This is a labourious process during which you have the
feeling you are are doing a lot of unnecessary work.
As if you are repackaging the same sandwich three
times in a row, first in a Java structure, then in the
intermediate structure, and then again in a Clean
structure... Waste of time (and the environment...)
;-)<br>
<br>
However, I had an idea: is it possible to use Clean's
dynamic types for this purpose? Instead of generating
some arbitrary intermediate type on the sender's side,
immediately generate a value that can be read by
Clean's dynamic type system. This would cut your work
in half: you don't have to write a parser on Clean's
side any more.<br>
<br>
I don't have any experience using Clean's dynamic
typing yet, therefore I decided to first ask whether
it is a fruitful approach before exploring it. Thus,
is this possible and is it a good idea? Of course, I'm
also open to other suggestions.<br>
<br>
Thanks in advance,<br>
<br>
Chide<br>
<br>
<br>
<br>
<br>
</font></p>
<br>
<fieldset class="mimeAttachmentHeader" target="_blank"></fieldset>
<br>
<pre>_______________________________________________
clean-list mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:clean-list@science.ru.nl" target="_blank">clean-list@science.ru.nl</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://mailman.science.ru.nl/mailman/listinfo/clean-list" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/clean-list</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>