Version française
Home     About     Download     Resources     Contact us    
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 ()

and:

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

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

I've CC'd this message to ocaml-beginners
[http://groups.yahoo.com/group/ocaml_beginners/] which is a more
appropriate place to discuss this stuff.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
PTHRLIB is a library for writing small, efficient and fast servers in C.
HTTP, CGI, DBI, lightweight threads: http://www.annexia.org/freeware/pthrlib/

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