caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Simon Cruanes <simon.cruanes.2007@m4x.org>
To: David Allsopp <dra-news@metastack.com>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Ocaml compiler documentation
Date: Thu, 3 Apr 2014 12:20:35 +0200	[thread overview]
Message-ID: <20140403101410.GA3176@fuck_yeah> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D9E0946BE1@Remus.metastack.local>

[-- Attachment #1: Type: text/plain, Size: 1490 bytes --]

Le Thu, 03 Apr 2014, David Allsopp a écrit :
> Yotam Barnoy wrote:
> > 2. What is demonstrated in lines 114-117 regarding polymorphic variant row fields:
> > 
> >  | Rtag of label * bool * core_type list
> >        (* [`A]                   ( true,  [] )
> >           [`A of T]              ( false, [T] )
> >           [`A of T1 & .. & Tn]   ( false, [T1;...Tn] )
> >           [`A of & T1 & .. & Tn] ( true,  [T1;...Tn] )
> >         *)
> >
> > What does the bool value represent?
> 
> It indicates that the constructor is constant, or that one of the types in the conjunction is "empty" (i.e. constant - I don't know what Jacques' terminology for that is!)

I might miss something, but wouldn't this be more readable if a variant
was used instead of booleans? Say,

type includes_constant =
    | IncludesConstant
    | DoesNotIncludeConstant

...
    | RTag of label * includes_constant * core_type list
        (*  [`A]            (IncludesConstant, [])
            [`A of T]       (DoesNotIncludeConstant, [T])
....

It would also be easier to extend. That's just nitpicking but I think it
would make the code more explicit by itself.

In addition, I never heard about conjunctions in variants, so I'm happy
Yotam started this initiative...

Cheers,

-- 
Simon

http://weusepgp.info/
key 49AA62B6 fingerprint 949F EB87 8F06 59C6 D7D3  7D8D 4AC0 1D08 49AA 62B6

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-04-03 10:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-31 15:39 Yotam Barnoy
2014-03-31 17:06 ` Milan Stanojević
2014-03-31 17:51   ` Yotam Barnoy
2014-04-01 10:03     ` Mark Shinwell
2014-04-03  2:48       ` Yotam Barnoy
2014-04-03  6:18         ` Mark Shinwell
2014-04-03  8:42         ` Jeremy Yallop
2014-04-03  9:05         ` David Allsopp
2014-04-03 10:20           ` Simon Cruanes [this message]
2014-04-03 10:46             ` David Allsopp
2014-04-03 18:17               ` Yotam Barnoy
2014-04-03  9:10         ` Gabriel Scherer
2014-04-03 20:16         ` Alain Frisch
2014-04-04  7:39           ` François Bobot
2014-04-14  6:12           ` Mark Shinwell
2014-04-14  7:44             ` Alain Frisch

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=20140403101410.GA3176@fuck_yeah \
    --to=simon.cruanes.2007@m4x.org \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    /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).