Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] let () =
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] let () =
On Tue, Aug 03, 2004 at 06:46:12PM +0400, Paul Argentoff wrote:
> Hello World!
> Can anyone answer my silly question: what does "let () = bla" really mean?

It means "evaluate 'bla' now".  In this instance, 'bla' is assumed to
be something which evaluates to / returns '()' (ie. the unit value).

There is another related syntax:

let _ = bla

which evaluates 'bla', and ignores the return type of 'bla', whatever
it might be.

Basically, these constructs are a way to evaluate something at
initialization time - usually when the program starts up, or the
module is loaded by some other means such as Dynlink.

These two syntaxes are equivalent:

let _ =
  f1 ();
  f2 ();
  f3 ()


f1 ();;
f2 ();;
f3 ();;

The first is used by people who don't like the ';;' syntax.

I've CC'd this message to ocaml-beginners
[] which is a more
appropriate place to discuss this stuff.


Richard Jones.
Merjis Ltd. - improving website return on investment
PTHRLIB is a library for writing small, efficient and fast servers in C.
HTTP, CGI, DBI, lightweight threads:

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: