<?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/cf4340f158bb79341f0102a9dd0603e7"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-12-24T09:49:57"
  subject="Re: [Caml-list] Frustrated Beginner"
  prev="2003/12/66a8d5c3e00e6eaf74c7910304840b3f"
  next="2003/12/eecce2c41acd3ffc1742dd3f9c2adf70"
  prev-in-thread="2003/12/66a8d5c3e00e6eaf74c7910304840b3f"
  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>
On Tue, 2003-12-23 at 15:03, Tyler Eaves wrote:

&gt; So why is O'Caml giving me so much trouble? 

Because the syntax is foreign.

&gt; My biggest source of problems seems to be the syntax. I'm totally
&gt; confused as far as ; vs ;; vs nothing, 

Yeah. The 'top level' is syntactically and semantically different
to the inner levels of Ocaml.

(1) At the top level you can write a sequence of definitions
or evaluate a sequence of expressions. This is not possible
anywhere else.

(2) If the definition/expression starts with a keyword
you don't need to use ';;' before it. For example:

	let f x = x
	let g x = x * x
	;;          (* needed because .. *)
	f x * g x   (* no keyword starts this *)
	;;          (* needed to force evaluation of expression NOW *)

At the inner level, you cannot write

	let h x =
		let f x = x
		let g x = x * x
		;;
		f x * g x
	;;

Inner expressions are evaluated 'entirely', not one at a time like
the top level. So you must write this:

	let h x =
		let f x = x in
		let g x = x * x in
		f x * g x
	;; (* end top level definition *)

You use ';' for sequencing evaluations:

	print_endline "Hello";
	print_endline "World"
	;;

This is a *single* expression evaluated, whereas

	print_endline "Hello"
	;;
	print_endline "World"
	;;

is two evaluations. (Try this in the 'ocaml' interpreter).


&gt; when to use ( ), and things of
&gt; the like. It doesn't help that the compiler is completly naive when it
&gt; comes to Syntax Errors. 

The reason is: the parser is a Yacc tool which means it
uses a LR parsing technique. When it can't parse something,
it has no choice than to say 'syntax error'. Its an error,
there's no way to say what the error is.

One way around this in LR parsers is to include error
productions in the grammar... that is, make the parser
parse common errors.

Another way, is to parse something more general than 
permitted first, then check constraints. This is certainly
done with type checking for example.


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

