From: Richard Jones <rich@annexia.org>
To: Brighten Godfrey <pbg@cs.berkeley.edu>
Cc: Jon Harrop <jon@ffconsultancy.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Record field label locality
Date: Wed, 13 Aug 2008 09:14:59 +0100 [thread overview]
Message-ID: <20080813081459.GA30690@annexia.org> (raw)
In-Reply-To: <BCFDFE2C-F8C5-4DCD-8B80-6CEA818308C7@cs.berkeley.edu>
On Tue, Aug 12, 2008 at 02:03:46PM -0700, Brighten Godfrey wrote:
> I think I see what you're getting at. Is it possible to define
> compositionality as follows?:
I think Jon means that you can copy and paste code around and it still
works.
> "Removing a type annotation from
> correct OCaml code results in correct OCaml code."
This is mostly correct. However very occasionally it is necessary to
help the compiler out by annotating expressions with types. I believe
this is because type inference used by OCaml is undecidable. You'll
notice this effect more often if you use OCaml's object system.
> I would claim that the current syntax (`g.Graph.nodes' in the above
> example) is effectively a type annotation that permits the type
> inference that `g' is a `Graph.t'. The annoying bit is that you are
> required to use every single time you use a record in `g'.
You might want to try renaming the Graph module, ie:
module G = Graph
... g.G.nodes ...
Or if you have control over the module itself, you could also try
renaming the fields to make them unique (eg. g_nodes), at which point
you can just 'open Graph'. There are different trade-offs to each
approach.
Rich.
--
Richard Jones
Red Hat
next prev parent reply other threads:[~2008-08-13 8:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-10 10:04 Brighten Godfrey
2008-08-10 19:38 ` [Caml-list] " Jon Harrop
2008-08-12 21:03 ` Brighten Godfrey
2008-08-13 0:12 ` Edgar Friendly
2008-08-13 1:17 ` Brighten Godfrey
2008-08-13 12:48 ` Edgar Friendly
2008-08-14 6:38 ` Brighten Godfrey
2008-08-14 10:11 ` David Allsopp
2008-08-13 1:51 ` blue storm
2008-08-13 8:14 ` Richard Jones [this message]
2008-08-13 9:30 ` Brighten Godfrey
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=20080813081459.GA30690@annexia.org \
--to=rich@annexia.org \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.com \
--cc=pbg@cs.berkeley.edu \
/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