Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Pierre Weis <Pierre.Weis@inria.fr>
To: garrigue@kurims.kyoto-u.ac.jp (Jacques GARRIGUE)
Cc: caml-list@inria.fr
Subject: Re: Warnings in ocaml
Date: Fri, 19 Feb 1999 19:32:46 +0100 (MET)	[thread overview]
Message-ID: <199902191832.TAA23736@pauillac.inria.fr> (raw)
In-Reply-To: <19990219213015B.garrigue@kurims.kyoto-u.ac.jp> from "Jacques GARRIGUE" at Feb 19, 99 09:30:15 pm

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

Could you please give me some interesting examples (Yes, I know you
can write this kind of functions, but I would like some examples where
it seems really painful to work it out otherwise).

Furthermore the point here is that this warning is useful, since we
had 2 undetected bugs into the Objective Caml system due to the lack
of this warning.

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

The Caml system example shows that this warning is useful, even for
the most experienced programmers, let alone the beginners that do not
know how to get the warning on if they know that it exists...

> ex. wrong code
> 	x = 3; ...
> 	  ^ should be <-

Or even x := 3.

> ex. right code
> 	f x y; ...
> where f: t1 -> t2 -> int has some interesting side-effect.

In this case the warning tells you that you may be have a further look
to your f function: is it necessary to mix side effects and purely
functional computation ? Very often, this is not necessary and
rewriting the code to avoid the mixing gets it clearer. If it is not
the case, you can tell it to the reader and write

let _ = f x y in
...

> * another common error with imperative code is partial application in
> a toplevel call inside a module
> 
> let _ =
>   somefunc hsj hjfhfd
> 
> somefunc takes 3 arguments but is only given 2. Since this is a
> let-definition no warning is printed while such a partial application
> is pretty meaningless.
> 
> Regards,
> 
> 	Jacques
> ---------------------------------------------------------------------------
> Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
> 		<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>

So you want another warning for dummy definitions at the toplevel of
modules when the application if partial ? Or may be you want to extend
the sequence warning to this case when the result is not unit ?

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/





  reply	other threads:[~1999-02-19 18:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-19 12:30 Jacques GARRIGUE
1999-02-19 18:32 ` Pierre Weis [this message]
1999-02-20 10:45   ` Markus Mottl
1999-02-22  9:55 Frank A. Christoph
1999-02-22 12:36 ` Xavier Leroy
1999-02-22 13:24   ` Anton Moscal
1999-02-22 15:06   ` Michael Hicks
1999-02-22 18:33 ` Ching-Tsun Chou
1999-02-22 13:45 Andrew Kay
1999-02-22 14:56 Andrew Kay
1999-02-22 17:25 Don Syme
1999-02-22 18:16 ` 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=199902191832.TAA23736@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=garrigue@kurims.kyoto-u.ac.jp \
    /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