caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Detecting missed checks for error indications in ML code
Date: Sun, 24 Jan 2021 17:07:29 +0100	[thread overview]
Message-ID: <20210124160729.iybuih6mmaquulcw@first.in-berlin.de> (raw)
In-Reply-To: <d4acfbd9-badb-78f1-0b48-839a2b8509d3@web.de>

Quoting  Markus Elfring <Markus.Elfring@web.de> (snt: 2021-01-24 16:52 +0100 CET) (rcv: 2021-01-24 16:52 +0100 CET):
> > But OCaml isn't just only a functional language.
> > It's also a typed language. And the type system can help you at this point.
> > You can use the option-type for indicating missing data.
> 
> I am looking more for possibilities to avoid missed checks for return values
> from some function calls.

I'm not sure what your problem is, which you want to solve.
Do you want to improve your programming (aka "coding") style?
Or do you have to deal with some code written by other people
and you fear that it's not using the type system to avoid the
problem of unclear (in the sense of "real value" vs. "error indicating
value") return values?

Do you have encountered realworld problems or are you asking just in
advance to avoid such problems in the future without having encountered
them so far?

> 
> 
> >> 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?
> >
> > No need to thest these kind of problems, as long as you use the type
> > system to help you as mentioned above.
> 
> Can it still happen then to overlook desirable checking of provided data?

If you encode the possible states of your return value as types,
then you have the advantage that when you match on the type, that
the compiler warns you about that (but if you ignore these warings, you
can get a runtime error with a non-matched value).
Also matching with the underscore can yield to unexpected results, if
used carelessly (or to avoid the compiler warnings, instead of writing
the correct match). But it often makes sense - just think about the
cases.



> 
> 
> > Since a while OCaml also offers a result-type, which you can use.
> 
> Do any programming interfaces need still to work without this special data type?

? Don't understand your question.


> 
> 
> > It might be better than the option type in more general cases.
> > And if predefined types don't offer what you are looking for,
> > just define your own type.
> 
> Customised types can be constructed only for new programming interfaces.

So write your own interface...

> Would you like to offer any companion functions for safer API variants?

?

Do you have questions on OCaml, or do you want us to write your code?


Ciao,
  Oliver

  reply	other threads:[~2021-01-24 16:07 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
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 [this message]
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=20210124160729.iybuih6mmaquulcw@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --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).