caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: "SooHyoung Oh" <shoh@duonix.com>
Cc: "caml-list" <caml-list@inria.fr>
Subject: Re: [Caml-list] Why warning?
Date: Wed, 12 Sep 2001 09:22:41 +0200 (MEST)	[thread overview]
Message-ID: <15263.3393.960387.171645@pc803> (raw)
In-Reply-To: <00b901c13b53$4e3bc9b0$1e01a8c0@hama>


SooHyoung Oh writes:
 > 
 > 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

In  the sequence  "expr1; expr2",  the result  of expr1  is discarded.
Thus, whenever the  result of expr1 is not "()" (i.e.  expr1 is not of
type "unit") the Caml compiler gives you a warning (you may have typed
";" instead of "," for instance, or any similar typo)

This warning may be disabled, as explained in the manual:

     http://caml.inria.fr/ocaml/htmlman/manual021.html

But you should rather write your code in a different way, having expr1
of type unit, or explicitly  ignoring its result. There are (at least)
two possibilities:

   let _ = expr1 in expr2

or better

   ignore (expr1); expr2

"ignore" is part of the Caml code library; see

   http://caml.inria.fr/ocaml/htmlman/manual031.html#@manual94

Best regards,
-- 
Jean-Christophe Filliatre (http://www.lri.fr/~filliatr)

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-09-12  7:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-12  6:22 SooHyoung Oh
2001-09-12  7:00 ` Christian RINDERKNECHT
2001-09-12  7:18 ` Sven
2001-09-12  7:22 ` Jean-Christophe Filliatre [this message]
2001-09-12  8:47 ` David Mentre
2001-09-13 16:39 ` Pierre Weis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15263.3393.960387.171645@pc803 \
    --to=jean-christophe.filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=shoh@duonix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).