caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Hendrik Boom <hendrik@topoi.pooq.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Detecting missed checks for error indications in ML code
Date: Sun, 24 Jan 2021 09:08:38 -0500	[thread overview]
Message-ID: <20210124140838.hnx2eeqn7xdvq624@topoi.pooq.com> (raw)
In-Reply-To: <41485ac7-50cf-08fe-4206-b9f863c4d2f5@web.de>

On Sun, Jan 24, 2021 at 12:42:23PM +0100, Markus Elfring wrote:
> Hello,
> 
> OCaml belongs also to the category of functional programming languages.
> Thus the last expression in a function usually becomes the result of
> the data processing which was specified in a ML source file.
> This would usually happen also if the return value from a function call
> indicates an error code (when a function implementation does not throw an exception
> according to an error situation).
> 
> I got the impression that corresponding error checks can occasionally be missing.
> How do you think about to detect such cases by advanced source code analysis?

Hard to do without knowing how the function encodes error information in its 
return value.  For example, is it success or failure that it indicates by 
returning the value zero?

A ver simple approach is to return a disjoint union -- a choice between 
a valid valid or an invalid value of another type.  THen, of course, the 
compiler's type checker will prevent any use of the valid value without a 
check being performed.

-- hendrik

  reply	other threads:[~2021-01-24 14:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24 11:42 Markus Elfring
2021-01-24 14:08 ` Hendrik Boom [this message]
2021-01-24 15:28   ` Markus Elfring
2021-01-24 14:34 ` Oliver Bandel
2021-01-24 15:52   ` Markus Elfring
2021-01-24 16:07     ` Oliver Bandel
2021-01-24 16:21       ` Markus Elfring
2021-01-25  3:59         ` Yawar Amin
2021-01-25 18:55           ` Markus Elfring
2021-01-24 16:18     ` Oliver Bandel
2021-01-24 16:50       ` Markus Elfring
2021-01-29 21:14         ` [Caml-list] Error handling in FPLs (Re: Detecting missed checks for error indications in ML code) Oliver Bandel
2021-01-30 11:51           ` Markus Elfring

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=20210124140838.hnx2eeqn7xdvq624@topoi.pooq.com \
    --to=hendrik@topoi.pooq.com \
    --cc=caml-list@inria.fr \
    /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).