<?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/12/ee71502c878f5927a1b190f3a67ba83e"
  from="Michael Jeffrey Tucker &lt;mtucker@e...&gt;"
  author="Michael Jeffrey Tucker"
  date="2003-12-23T06:33:06"
  subject="Re: [Caml-list] Frustrated Beginner"
  prev="2003/12/fe21fe7081ed319ea8db5f5750352671"
  next="2003/12/5cd1c85734f3ce5ee910df85c3c7f2dc"
  prev-in-thread="2003/12/fe21fe7081ed319ea8db5f5750352671"
  next-in-thread="2003/12/841e77b1ddce392241971f685edf5d8a"
  prev-thread="2003/12/4c6ae63cd6b1e8a8f33149859cfd695c"
  next-thread="2003/12/356d10902619a410f7549b83a9f58963"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/9ba2203dc9bd04094ddf59c3d0284deb"
  from="Tyler Eaves &lt;tyler@m...&gt;"
  author="Tyler Eaves"
  date="2003-12-23T04:00:52"
  subject="[Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/a0b0531fb37dc533bd881d98808bed89"
  from="jayanta nath &lt;jnath001@c...&gt;"
  author="jayanta nath"
  date="2003-12-23T04:19:23"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
<msg 
  url="2003/12/38d229d1475e914de083edc5b906873c"
  from="Matt Gushee &lt;mgushee@h...&gt;"
  author="Matt Gushee"
  date="2003-12-23T05:34:55"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/c5acd59185f825661ce2c49a28f5d0a9"
  from="Tyler Eaves &lt;tyler@m...&gt;"
  author="Tyler Eaves"
  date="2003-12-23T06:13:04"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/fe21fe7081ed319ea8db5f5750352671"
  from="Michael Vanier &lt;mvanier@c...&gt;"
  author="Michael Vanier"
  date="2003-12-23T06:21:18"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
<msg 
  url="2003/12/ee71502c878f5927a1b190f3a67ba83e"
  from="Michael Jeffrey Tucker &lt;mtucker@e...&gt;"
  author="Michael Jeffrey Tucker"
  date="2003-12-23T06:33:06"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/841e77b1ddce392241971f685edf5d8a"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2003-12-23T12:17:01"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/18dcbc2beccf1b644f6ab95457ee963f"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-23T20:29:52"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
</msg>
</msg>
<msg 
  url="2003/12/5cd1c85734f3ce5ee910df85c3c7f2dc"
  from="Shawn Wagner &lt;shawnw@s...&gt;"
  author="Shawn Wagner"
  date="2003-12-23T06:38:09"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
<msg 
  url="2003/12/35fc0995ea1ae8ccceae6d350991db06"
  from="Matt Gushee &lt;mgushee@h...&gt;"
  author="Matt Gushee"
  date="2003-12-23T06:47:10"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
</msg>
</msg>
<msg 
  url="2003/12/4b03d6302b877c38d87a8293569cdb8e"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-23T05:58:48"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/d0ac30fab0ff57144724f60d9ac5597e"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-23T06:53:39"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/cb5267240922f26dddcd0cc2ff382f2b"
  from="Tyler Eaves &lt;tyler@m...&gt;"
  author="Tyler Eaves"
  date="2003-12-23T07:23:39"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/4ea2bc69089f80a24ff1562317bbfd41"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-23T08:26:37"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/12/e8e0e512d3d35fafebac0f20d8832cba"
  from="Tom Murray &lt;yozhik@c...&gt;"
  author="Tom Murray"
  date="2003-12-23T06:20:47"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
<msg 
  url="2003/12/6d5f7b024ef3f697fac55342de6fce33"
  from="Stefano Zacchiroli &lt;zack@b...&gt;"
  author="Stefano Zacchiroli"
  date="2003-12-23T08:53:03"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/f895facc88274b349ffb2fd4d5b03bae"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-12-23T16:47:24"
  subject="[Caml-list] Ocaml syntax.">
<msg 
  url="2003/12/c60a0e39a33234213fabb8de608e20a2"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-23T20:32:18"
  subject="Re: [Caml-list] Ocaml syntax.">
<msg 
  url="2003/12/7511a52ffbb5f995bcc51cc1619bb2af"
  from="Eric Merritt &lt;cyberlync@y...&gt;"
  author="Eric Merritt"
  date="2003-12-23T21:03:47"
  subject="Re: [Caml-list] Ocaml syntax.">
</msg>
</msg>
<msg 
  url="2003/12/5f24e60286352a813888ef91b50b6578"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-12-23T21:52:47"
  subject="Re: [Caml-list] Ocaml syntax.">
<msg 
  url="2003/12/eecce2c41acd3ffc1742dd3f9c2adf70"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-12-24T10:29:37"
  subject="Re: [Caml-list] Ocaml syntax.">
<msg 
  url="2003/12/0e341a41b90d25333128238049ca470a"
  from="Peter Jolly &lt;peter@j...&gt;"
  author="Peter Jolly"
  date="2003-12-24T11:42:05"
  subject="Re: [Caml-list] Ocaml syntax.">
<msg 
  url="2003/12/24be3928a72aa840fb93c85a339eb598"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-12-24T12:19:48"
  subject="Re: [Caml-list] Ocaml syntax.">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/12/9d57c140fb3d5f1ec182f811b5cfc0f7"
  from="dmitry grebeniuk &lt;gds-mlsts@m...&gt;"
  author="dmitry grebeniuk"
  date="2003-12-30T08:13:16"
  subject="Re: [Caml-list] Ocaml syntax.">
<msg 
  url="2003/12/e9066def8bab8a60fd712d2df0ec2bd1"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-12-30T17:48:52"
  subject="Re: [Caml-list] Ocaml syntax.">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/12/bec9c497ea5c688e3fead65fc14a0692"
  from="Samuel Lacas &lt;Samuel.Lacas@t...&gt;"
  author="Samuel Lacas"
  date="2003-12-23T10:25:48"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/9056423d13a1f0263d868ffcc335f22c"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-23T11:01:44"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/df4c7693f5aefbfc3ce2795223de537f"
  from="Oleg Trott &lt;oleg_trott@c...&gt;"
  author="Oleg Trott"
  date="2003-12-23T14:35:11"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/4614d0a74f49864cf1157d99ade90e8a"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-23T20:32:12"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/12/72d055fb36bbf52cf1f3596e7e17c798"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-12-23T16:07:46"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/48c1bdc28352b8ffaa6ab8cdc1029b85"
  from="Sven Luther &lt;sven.luther@w...&gt;"
  author="Sven Luther"
  date="2003-12-23T16:20:08"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/8aa1331578f5cd94bfcb4f5f0ff2a00e"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-12-23T16:52:37"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/48652a1c2e1c09264c1dedd530964ab3"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-23T20:33:28"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/74ed410e6ed55f048ca17bf40f5e9784"
  from="Issac Trotts &lt;ijtrotts@u...&gt;"
  author="Issac Trotts"
  date="2003-12-24T10:40:22"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
</msg>
</msg>
<msg 
  url="2003/12/683eeee2d3a2d17bdea055ebdd10d273"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-12-23T17:36:13"
  subject="Re: [Caml-list] Frustrated Beginner">
<msg 
  url="2003/12/66a8d5c3e00e6eaf74c7910304840b3f"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-12-24T09:35:10"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/12/cf4340f158bb79341f0102a9dd0603e7"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-12-24T09:49:57"
  subject="Re: [Caml-list] Frustrated Beginner">
</msg>
</msg>
</thread>

<contents>
Hi Tyler,

&gt; &gt;       match foo with
&gt; &gt;       | None -&gt; print_endline "Nothing"; ""
&gt; &gt;       | Some x -&gt; print_endline x; x
&gt;
&gt; If I understand the match syntax correctly, in this case, x takes the
&gt; value of foo?

You're pretty close - in this case, you can think of foo as being a
structure that contains a tag and potentially a valid value. In C this
might be represented by:

struct foo_type {
	enum {Some, None} opt;
	value_t val;
};

If the opt field of the structure is set to Some, then you are free to
look at the val field. If it's none, then the value in the val field is
unspecified and should be ignored (of course this is more stringently
enforced in OCaml). In OCaml an "option type" variable has either the
value "Some xxx" or "None" where xxx is a value. So, a "string option"
variable might have the value Some "hi", Some "qwery" or None. If you
pattern match on a variable of this type, as in:

match foo with
| None -&gt; "Argh! No value."
| Some x -&gt; x

Then, you are creating a new binding for x, where x will be assigned the
value portion. So, in the example values above, this code will evaluate
to (in order):

"hi"
"qwery"
"Argh! No value."

Hope that helps,
Mike

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

