caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Kristopher Micinski <krismicinski@gmail.com>
To: David MENTRE <dmentre@linux-france.org>
Cc: Francois Berenger <berenger@riken.jp>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] some beautiful OCaml code
Date: Wed, 9 Jan 2013 09:15:04 -0500	[thread overview]
Message-ID: <CAF1Sy-EKkKotBVUhpyL4evdcmujL1a8s0ckT25PTrqS-8cY8dg@mail.gmail.com> (raw)
In-Reply-To: <CAC3Lx=bkQMo50rs=zjUpz==y_RzUffLCCDX5wcNK0Q=Mn_j5xQ@mail.gmail.com>

On Wed, Jan 9, 2013 at 3:38 AM, David MENTRE <dmentre@linux-france.org> wrote:
> Hello OCaml experts,
>
> 2013/1/9 Francois Berenger <berenger@riken.jp>:
> I never fully grasped polymorphic variants compared to regular ones
> but I always had the feeling the polymorphic variants where less safe
> that variants because they would allow more possibility to mix
> unrelated things[1].
>


I would say that it's not that polymorphic variants are less safe, but
they can occasionally be more painful, because of the explicit type
signatures, and because of type inference you can end up with some
ugly errors.  It's typically recommended that when you use polymorphic
variants you use explicit annotations.

I suppose they could be unsafe if, say, you had two similarly named
constructors with the same signature that had different semantics
between different modules.  But that would probably be bad style to
begin with.

There's a StackOverflow guide on when to use polymorphic variants, I
agree with the answer:

http://stackoverflow.com/questions/9367181/variants-or-polymorphic-variants

Kris

      parent reply	other threads:[~2013-01-09 14:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09  3:48 Francois Berenger
2013-01-09  8:38 ` David MENTRE
2013-01-09 10:06   ` Malcolm Matalka
2013-01-10  8:13     ` David MENTRE
2013-01-09 13:15   ` AW: " Gerd Stolpmann
2013-01-09 14:15   ` Kristopher Micinski [this message]

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=CAF1Sy-EKkKotBVUhpyL4evdcmujL1a8s0ckT25PTrqS-8cY8dg@mail.gmail.com \
    --to=krismicinski@gmail.com \
    --cc=berenger@riken.jp \
    --cc=caml-list@inria.fr \
    --cc=dmentre@linux-france.org \
    /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).