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] Why warning?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-09-12 (07:33)
From: Christian RINDERKNECHT <rinderkn@h...>
Subject: Re: [Caml-list] Why warning?
Hi Soo-Hyoung,

On Wed, Sep 12, 2001 at 03:22:32PM +0900, SooHyoung Oh wrote:
> Why is this warning occurred?
> Where can I get infomation about this? (ex: 'nnn' page on manual, articles
> or books)
> # 1; 2;;
> Warning: this expression should have type unit.
> - : int = 2

The sequence operator ; (semi-colon) is used for composing expressions
that may perform some side-effects. This is the typical construct of
imperative languages like Pascal. In Caml, such expressions are given
the type unit, and the only value of type unit is noted (). It
is generally considered as good practice to:

  (1) make sure that the expressions are of type unit, except maybe
      the last one, ie. given <e1>; <e2>; .... ; <en>; <e'>, then
      <e1>, <e2>, ..., <en> should have type unit;
  (2) use keywords "begin" and "end" to enclose your sequence:

So, in your example, 1 is of type int, not unit (hence the warning).

For historical reason, this behaviour is not mandatory, and you can
turn off this warning in batch mode usign the -W s command-line
option. Please refer to for other warnings.

As far as I am concerned, all warnings are turned into errors:)

Hope this helps,



Christian Rinderknecht                     Phone +82 42 866 6147
Network Architecture Laboratory            Fax   +82 42 866 6154
Information and Communications University  WWW
58-4 Hwaam-dong, Yuseong-gu, Daejeon, 
305-752, Korea
Bug reports:  FAQ:
To unsubscribe, mail  Archives: