<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/07/43df2b95e7a15bf9dc8313265ae49889"
  from="Chris Clearwater &lt;chris@s...&gt;"
  author="Chris Clearwater"
  date="2003-07-23T22:41:24"
  subject="Re: [Caml-list] Functor implementation"
  prev="2003/07/f90a8a17360dae1f3d044706aa82754d"
  next="2003/07/d9552a523f855e9aec83425fe88835cb"
  prev-in-thread="2003/07/6a3ad155513fe4dcb441ceaecc207515"
  next-in-thread="2003/07/566ce50e8a50d43803c753eee1449a3c"
  prev-thread="2003/07/7347ef3d79f516ef8692babe85c8791a"
  next-thread="2003/07/97b33d8e4a056a0adde1f92c7edafae0"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Functor implementation">
<msg 
  url="2003/07/29d3d4246f320c31566fbe65671742e3"
  from="Chris Clearwater &lt;chris@s...&gt;"
  author="Chris Clearwater"
  date="2003-07-23T11:56:50"
  subject="[Caml-list] Functor implementation">
<msg 
  url="2003/07/6a3ad155513fe4dcb441ceaecc207515"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-07-23T13:01:40"
  subject="Re: [Caml-list] Functor implementation">
<msg 
  url="2003/07/43df2b95e7a15bf9dc8313265ae49889"
  from="Chris Clearwater &lt;chris@s...&gt;"
  author="Chris Clearwater"
  date="2003-07-23T22:41:24"
  subject="Re: [Caml-list] Functor implementation">
<msg 
  url="2003/07/566ce50e8a50d43803c753eee1449a3c"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-07-24T15:16:16"
  subject="Re: [Caml-list] Functor implementation">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
On Wed, Jul 23, 2003 at 03:01:32PM +0200, Xavier Leroy wrote:
&gt; Now, let me warn you about the following code:
&gt; 
&gt; &gt; let compare x y =
&gt;     let cmp = x - y in if cmp &gt; 0 then GT else if cmp &lt; 0 then LT else EQ
&gt; 
&gt; which doesn't work if x and y are sufficiently far apart
&gt; (e.g. x = max_int and y = min_int).
&gt; 
&gt; - Xavier Leroy

Ahh, thanks, functors now fit nicely in my head. And yeah that cmp
function was kind of braindead. I dont know why I didnt simply write it
as : let cmp x y = if x &gt; y then GT else if x &lt; y then LT else EQ. But
it would still be nice if the built in comparison function returned a
sum type. And there was provided a helper function:
let comparison_of_int x = if x &gt; 0 then GT else if x &lt; 0 then LT else EQ.
Maybe "ordering" is a more appropriate name. Also, true and false appear
to be a sum type: type bool = True | False, except you can't have lower
case constructor names. Does this signal the fact that there is some
kind of limitation with having primitive sum types?

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

