caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "AUGER Cédric" <Cedric.Auger@lri.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: Subtyping structurally-equivalent records, or something like it?
Date: Tue, 4 May 2010 12:33:58 +0200	[thread overview]
Message-ID: <20100504123358.01c98f72cauger@lri.fr@Sedrikov.home> (raw)
In-Reply-To: <slrnhtp24f.bpc.sylvain@gallu.homelinux.org>

I am not expert in Ocaml, is the following the same in terms
of performances as the phantom types?

type kinematic = ...

type force = Force of kinematic
type momentum = Moment of kinematic
...

That is does the constructor introduce an overhead or not?
As there is only one constructor, no overhead should be done in an
optimized compiler.

So general functions should use a kinematic -> [Type]
and a specialized function, force -> [Type] and so on...

I understand this version is not as handy as the phantom types, as we
need to use "match ... with Force f -> ..." or at least "let Force f
= ... in ...", but my question is only in terms of efficiency;
obviously phantom types are more or equally efficient than what I
exposed, but does the reciproque also holds?


  reply	other threads:[~2010-05-04 10:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-01 19:55 [Caml-list] " Dario Teixeira
2010-05-01 20:01 ` Sylvain Le Gall
2010-05-04 10:33   ` AUGER Cédric [this message]
     [not found]   ` <4429.86797211251$1272970133@news.gmane.org>
2010-05-04 11:53     ` Sylvain Le Gall
2010-05-04 12:47       ` [Caml-list] " rossberg
2010-05-04 13:42         ` Sylvain Le Gall
2010-05-04 15:18           ` [Caml-list] " Fabrice Le Fessant
2010-05-05  9:31         ` Goswin von Brederlow
2010-05-05 12:12           ` rossberg
2010-05-05 16:46             ` Goswin von Brederlow
2010-05-04 13:37       ` Edgar Friendly
2010-05-05  9:33         ` Goswin von Brederlow
2010-05-05 11:10         ` Yaron Minsky

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=20100504123358.01c98f72cauger@lri.fr@Sedrikov.home \
    --to=cedric.auger@lri.fr \
    --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).