<div dir="ltr"><div>(For general interest)</div><div><div class="gmail_extra"><br><div class="gmail_quote">2013/11/22 Marc Feeley <span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca" target="_blank">feeley@iro.umontreal.ca</a>></span><br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><br>
On Nov 22, 2013, at 1:40 AM, Mikael <<a href="mailto:mikael.rcv@gmail.com">mikael.rcv@gmail.com</a>> wrote:<br>
<br>
> Francois,<br>
><br>
> Two Q:s:<br>
><br>
> First, when you got a very basic sample app like a DOM-based hangman going, feel free to share code<br>
><br>
> Second, how is the type mapping - fixnums, flonums, bignums all wrapped to JS double, Scheme string and vector to JS string and vector?<br>
<br></div></blockquote><div>(1) </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
</div>The data representation is customizable with two options for each type.  There is a "natural" mapping (Scheme number -> JS number, Scheme vector -> JS array, etc) and one which uses classes.<br>
<br></blockquote><div>(2) </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Note that the natural mapping may violate some of the Scheme semantics.  For example, JS numbers don't carry the concept of exactness, and JS strings are immutable whereas Scheme strings are mutable.  On the other hand the natural mapping may be useful in cases where some details of the Scheme semantics are not important (the generated JS code is easier to read/understand, the generated JS code can be more easily interfaced with existing JS libraries, etc).  A mapping which respects the Scheme semantics is:<br>


<br>
- Fixnums are mapped to JS numbers<br>
- Booleans are mapped to JS booleans<br>
- Symbols are mapped to JS strings<br>
- Vectors are mapped to JS arrays<br>
- Procedures are mapped to JS functions<br>
- Strings, characters, flonums (and other numbers), and pairs are implemented with JS classes<br>
<br></blockquote><div> </div><div><br></div><div>Wait, first(1) you suggest there's a customizable option, and then second(2) you outline a holistic approach for Scheme-JS type mapping.<div><br></div><div>How is it? And if anything is configurable, where's the switch?<br>

</div></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Unfortunately, this mapping makes it expensive to implement some Gambit specific operations, such as ##subtype, ##subtype-set! and</blockquote><div><br></div><div>Didn't even hear about ##subtype* til now - Any use of JS turns out to be for some special purpose anyhow, so that there's some real corner case of Scheme execution in this environment that has a low performance is really completely cool. </div>

<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> ##vector-ref.</blockquote><div><br></div><div>

Wait, why, can't this just be ordinarily expanded to JS' variable[index]?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

So it may be necessary to implement non immediate data (vectors, structures, etc) uniformly with classes when using the standard Gambit runtime system.  </blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

I haven't explored this aspect much, but it may be that supporting all the Gambit primitives isn't practical.</blockquote><div><br></div><div>(same note as above re special purpose here)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

  A solution may be to have two modes (Standard Scheme and Gambit Scheme) so the user can select the best mode for his needs.<br></blockquote><div><br></div><div>What would the difference be approx here?</div><div> </div>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888"><br>
Marc<br>
<br>
</font></span></blockquote></div><br></div></div></div>