Browse thread
[Caml-list] Frustrated Beginner
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Sven Luther <sven.luther@w...> |
| Subject: | Re: [Caml-list] Frustrated Beginner |
On Tue, Dec 23, 2003 at 11:11:19AM -0500, Brian Hurt wrote:
> > My biggest source of problems seems to be the syntax. I'm totally
> > confused as far as ; vs ;; vs nothing, when to use ( ), and things of
> > the like.
>
> This took some rethinking on my part as well. The trick is to remember
> that ';' is an operator, like '+' and '.' are. Actually, the best
> comparison is with the comma operator in C. If the type of '+' is int ->
> int -> int ('+' takes two int parameters and returns an int), then the
> type of the ';' operator is unit -> 'a -> 'a (or more correctly, 'a -> 'b
> -> 'b). One you start thinking of ';' as an operator and not a statement
> seperator, it becomes more obvious that an ocaml function body is simply a
> single expression, and not a series of statements. ';;' is more close to
> what ';' in most languages mean- it's what ends an expression.
Mmm, not really convinced. For me ;, is a shortcut for :
let () = ... in
Actually, i believe that both constructs result in the exact same code.
That said, i guess it would not really help someone coming from the
imperative world, and not used to the let ... = ... in construct.
Friendly,
Sven Luther
-------------------
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