<div dir="ltr">I think I'd be happy saying that portable code should use the fromInt functions.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 November 2016 at 10:01, Ramana Kumar <span dir="ltr"><<a href="mailto:Ramana.Kumar@cl.cam.ac.uk" target="_blank">Ramana.Kumar@cl.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">(Minor correction, it was ``WordFromInt W8`` rather than ``W8FromInt``.)<br><br><div>Another more straightforward suggestion is concrete syntax directly corresponding to the AST literals, e.g.:<br></div><div>8w3 -> Word8 0w3<br></div><div>64w3 -> Word64 0w3<br></div><div>The problem here is that it's not SML compatible. However, we could additionally have 0w3 mapping to the 64-bit version.<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 29 November 2016 at 09:57, Ramana Kumar <span dir="ltr"><<a href="mailto:Ramana.Kumar@cl.cam.ac.uk" target="_blank">Ramana.Kumar@cl.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Good point, Michael. I didn't think about the problem of redefining int_to_word or Word8.fromInt - that makes targeting them in the parser seem less appealing to me. (However, note that my suggestion did not involve targeting Word8.fromInt from the parser.)<br><br></div>Scott: my suggestion was to parse "0w3" as ``Word64 0w3`` and not have special Word8 literals. To write programs with word8s, you must use Word8.fromInt from the basis library (which maps to the primitive ``W8FromInt``).<br></div><div class="m_7185776040808750288HOEnZb"><div class="m_7185776040808750288h5"><div class="gmail_extra"><br><div class="gmail_quote">On 29 November 2016 at 09:41, Scott Owens <span dir="ltr"><<a href="mailto:S.A.Owens@kent.ac.uk" target="_blank">S.A.Owens@kent.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don’t think my suggestion is that weird. The semantics of the language would change so that int_to_word as a name has a special, explicitly documented meaning. You could require that any definition of int_to_word has to have type int -> WordN.t for some N IN {8, 32, 64} or something like that, to catch the error at a better location. I didn’t really understand Ramana’s suggestion.<br>
<span class="m_7185776040808750288m_100876525721995234HOEnZb"><font color="#888888"><br>
Scott<br>
</font></span><div class="m_7185776040808750288m_100876525721995234HOEnZb"><div class="m_7185776040808750288m_100876525721995234h5"><br>
> On 2016/11/28, at 22:24, <a href="mailto:Michael.Norrish@data61.csiro.au" target="_blank">Michael.Norrish@data61.csiro.a<wbr>u</a> wrote:<br>
><br>
> The other idea I had, which would at least allow the parser to target the AST (suggestions below would suggest we drop one or both of the Word{8,64} constructors), was to have 0w3 go to Word8, and 0W3 go to Word64…<br>
><br>
> Scott’s suggestion is pretty weird incidentally, it would mean that inserting<br>
><br>
>   fun int_to_word x = x<br>
><br>
> in a program that doesn’t contain that string anywhere could cause it to fail to typecheck.  I mildly prefer Ramana’s because to get the comparable problem there, you’d have to insert the slightly more involved<br>
><br>
>   structure Word8 = struct fun fromInt i = I end;<br>
><br>
> which would break pieces of code with no textually apparent references to Word8.<br>
><br>
> Michael<br>
><br>
> From: Ramana Kumar <<a href="mailto:Ramana.Kumar@cl.cam.ac.uk" target="_blank">Ramana.Kumar@cl.cam.ac.uk</a>><br>
> Date: Monday, 28 November 2016 at 20:29<br>
> To: Scott Owens <<a href="mailto:S.A.Owens@kent.ac.uk" target="_blank">S.A.Owens@kent.ac.uk</a>><br>
> Cc: "Norrish, Michael (Data61, Canberra City)" <<a href="mailto:Michael.Norrish@data61.csiro.au" target="_blank">Michael.Norrish@data61.csiro.<wbr>au</a>>, "<a href="mailto:developers@cakeml.org" target="_blank">developers@cakeml.org</a>" <<a href="mailto:developers@cakeml.org" target="_blank">developers@cakeml.org</a>><br>
> Subject: Re: [CakeML-dev] [CakeML-Dev] targeting word literal constructors in AST<br>
><br>
> I like Scott's suggestion.<br>
><br>
> On 28 November 2016 at 20:23, Scott Owens <<a href="mailto:S.A.Owens@kent.ac.uk" target="_blank">S.A.Owens@kent.ac.uk</a>> wrote:<br>
> Or we could have the parser map 0w3 to something like “int_to_word 3” and leave it in the programmers control, and have the basis start with a default.<br>
><br>
> Scott<br>
><br>
> > On 2016/11/28, at 07:36, Ramana Kumar <<a href="mailto:Ramana.Kumar@cl.cam.ac.uk" target="_blank">Ramana.Kumar@cl.cam.ac.uk</a>> wrote:<br>
> ><br>
> > I doubt we want to go down that path...<br>
> ><br>
> > Here's a (somewhat random) suggestion: word literals (0w3 etc.) are mapped to Word64.word, and to get bytes via parser you need to use Word8.fromInt.<br>
> ><br>
> > On 28 November 2016 at 15:35, <<a href="mailto:Michael.Norrish@data61.csiro.au" target="_blank">Michael.Norrish@data61.csiro.<wbr>au</a>> wrote:<br>
> > Presumably SML allows type inference to figure out the width in the same way that numeric operations get overload-resolved:<br>
> ><br>
> ><br>
> ><br>
> > (* Poly/ML *)<br>
> ><br>
> > > Word8.+(0w3, 0w4);<br>
> ><br>
> > val it = 0wx7: Word8.word<br>
> ><br>
> > > Word64.+(0w3, 0w4);<br>
> ><br>
> > val it = 0wx7: Word64.word<br>
> ><br>
> ><br>
> ><br>
> > Michael<br>
> ><br>
> ><br>
> ><br>
> > From: Ramana Kumar <<a href="mailto:Ramana.Kumar@cl.cam.ac.uk" target="_blank">Ramana.Kumar@cl.cam.ac.uk</a>><br>
> > Date: Monday, 28 November 2016 at 11:46<br>
> > To: "Norrish, Michael (Data61, Canberra City)" <<a href="mailto:Michael.Norrish@data61.csiro.au" target="_blank">Michael.Norrish@data61.csiro.<wbr>au</a>><br>
> > Cc: "<a href="mailto:developers@cakeml.org" target="_blank">developers@cakeml.org</a>" <<a href="mailto:developers@cakeml.org" target="_blank">developers@cakeml.org</a>><br>
> > Subject: Re: [CakeML-Dev] targeting word literal constructors in AST<br>
> ><br>
> ><br>
> ><br>
> > SML does not distinguish syntactically. I guess we might have to invent some syntax...?<br>
> ><br>
> ><br>
> ><br>
> > On 28 November 2016 at 11:03, <<a href="mailto:Michael.Norrish@data61.csiro.au" target="_blank">Michael.Norrish@data61.csiro.<wbr>au</a>> wrote:<br>
> ><br>
> > There are both Word8 and Word64 constructors for word literals in the AST type. How are the parser or lexer meant to figure out which any piece of syntax corresponds to?<br>
> ><br>
> > Michael<br>
> ><br>
> > ______________________________<wbr>_________________<br>
> > Developers mailing list<br>
> > <a href="mailto:Developers@cakeml.org" target="_blank">Developers@cakeml.org</a><br>
> > <a href="https://lists.cakeml.org/listinfo/developers" rel="noreferrer" target="_blank">https://lists.cakeml.org/listi<wbr>nfo/developers</a><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > ______________________________<wbr>_________________<br>
> > Developers mailing list<br>
> > <a href="mailto:Developers@cakeml.org" target="_blank">Developers@cakeml.org</a><br>
> > <a href="https://lists.cakeml.org/listinfo/developers" rel="noreferrer" target="_blank">https://lists.cakeml.org/listi<wbr>nfo/developers</a><br>
> ><br>
> ><br>
> > ______________________________<wbr>_________________<br>
> > Developers mailing list<br>
> > <a href="mailto:Developers@cakeml.org" target="_blank">Developers@cakeml.org</a><br>
> > <a href="https://lists.cakeml.org/listinfo/developers" rel="noreferrer" target="_blank">https://lists.cakeml.org/listi<wbr>nfo/developers</a><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Developers mailing list<br>
> <a href="mailto:Developers@cakeml.org" target="_blank">Developers@cakeml.org</a><br>
> <a href="https://lists.cakeml.org/listinfo/developers" rel="noreferrer" target="_blank">https://lists.cakeml.org/listi<wbr>nfo/developers</a><br>
<br>
______________________________<wbr>_________________<br>
Developers mailing list<br>
<a href="mailto:Developers@cakeml.org" target="_blank">Developers@cakeml.org</a><br>
<a href="https://lists.cakeml.org/listinfo/developers" rel="noreferrer" target="_blank">https://lists.cakeml.org/listi<wbr>nfo/developers</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>