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
Re: Warnings in ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-02-22 (12:31)
From: Frank A. Christoph <christo@n...>
Subject: Re: Warnings in ocaml
 Jacques GARRIGUE <> wrote:
>I have a few comments about new warnings in ocaml.
>* having a warning when a function doesn't return unit in a sequence
>may catch some bugs, but this is a pain with imperative programming
>style, where you may not be interested by the result of a function but
>just by its side-effects. Of course you can switch off the warning,
>but I'm not sure having it on is a good default, since the default
>mode should be normative.
>ex. wrong code
> x = 3; ...
>   ^ should be <-
>ex. right code
> f x y; ...
>where f: t1 -> t2 -> int has some interesting side-effect.

I copied from SML and defined a procedure "ignore":

  let ignore k =
    let _ = k in ()

so now I would write:

  ignore (f x y); ...

I agree that it can be a pain to be explicit about this sometimes, but "ignore" makes it fairly transparent.

BTW, this procedure is a good candidate for addition to the standard library.