<?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/11/b23fea5c7f6cfe4c65fec96ce9078773"
  from="Julien Demouth &lt;julien.demouth@f...&gt;"
  author="Julien Demouth"
  date="2003-11-05T09:46:21"
  subject="Re: [Caml-list] function overloading"
  prev="2003/11/e00f3df02875aef67715de70b65c6100"
  next="2003/11/57a8412c073003a82fda51c70c548daf"
  prev-in-thread="2003/11/e00f3df02875aef67715de70b65c6100"
  next-in-thread="2003/11/57a8412c073003a82fda51c70c548daf"
  prev-thread="2003/11/7d1a89526a373d9c8ad55df4f4d4ad97"
  next-thread="2003/11/834f32c016ca6e13fe4db785db200a2d"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] function overloading">
<msg 
  url="2003/11/e00f3df02875aef67715de70b65c6100"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-11-05T08:57:22"
  subject="[Caml-list] function overloading">
<msg 
  url="2003/11/b23fea5c7f6cfe4c65fec96ce9078773"
  from="Julien Demouth &lt;julien.demouth@f...&gt;"
  author="Julien Demouth"
  date="2003-11-05T09:46:21"
  subject="Re: [Caml-list] function overloading">
</msg>
<msg 
  url="2003/11/57a8412c073003a82fda51c70c548daf"
  from="Issac Trotts &lt;ijtrotts@u...&gt;"
  author="Issac Trotts"
  date="2003-11-05T10:03:52"
  subject="Re: [Caml-list] function overloading">
<msg 
  url="2003/11/51d232db64cdde1facee1368a5853bbc"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-11-05T17:51:39"
  subject="Re: [Caml-list] function overloading">
</msg>
</msg>
<msg 
  url="2003/11/dce69ef2d7853d6760e22f2fdaaedce0"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-11-07T08:06:35"
  subject="Re: [Caml-list] function overloading">
</msg>
</msg>
</thread>

<contents>
Dustin Sallings wrote:
&gt; 
&gt;     I swear I found an example demonstrating how to do pattern matching 
&gt; based on the type of an argument, but every pattern matching example I 
&gt; can find now seems to be focused on value and not type.
&gt; 

You've probably read an example of what GCaml offers. GCaml is an 
extension of OCaml allowing some "extensional polymorphic extensions". 
But you have to know that it is based on an old OCaml version. Have a 
look at:

	http://pauillac.inria.fr/~furuse/generics/

&gt;     I'm trying to do something like this:
&gt; 
&gt; let print_poly x = match x with
&gt;     | (x: bool) -&gt; print_bool x
&gt;     | (x: int) -&gt;  print_int x
&gt; ;;
&gt; 
&gt;     Can someone tell me what I'm doing wrong (or perhaps tell me why I 
&gt; shouldn't be doing this at all)?
&gt; 

It cannot work with OCaml because all the expressions in a pattern 
matching have to have the same type. The pattern matching is based on 
variables values and not on their types. It is how the language works.

Julien


-------------------
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>

