caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: briand@aracnet.com
To: Ville-Pertti Keinonen <will@exomi.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] duplicate record labels and modules
Date: Tue, 11 May 2004 09:10:59 -0700	[thread overview]
Message-ID: <16544.64275.204812.673065@soggy.deldotd.com> (raw)
In-Reply-To: <68643590-A31D-11D8-A8EF-000393863F70@exomi.com>

>>>>> "Ville-Pertti" == Ville-Pertti Keinonen <will@exomi.com> writes:

  Ville-Pertti> On May 11, 2004, at 8:13 AM, briand@aracnet.com wrote:

  >> Consider the following :
  >> 
  >> let a = {Foo.n1=1; Foo.n2=2; Foo.a=(- 1.0)} in
  >> let b = {Bar.n1=4; Bar.n2=(- 5); Bar.b=77.} in
  >> Printf.printf "%d\n" a.Foo.n1;
  >> Printf.printf "%d\n" b.Bar.n1;

  Ville-Pertti> If you want to make it slightly less verbose, you can say

  Ville-Pertti> module F = Foo
  Ville-Pertti> module B = Bar

  Ville-Pertti> Or you could use "let module ... in".

That's useful.  I need to read the chapter on language extensions more
closely.

  Ville-Pertti> Alternately, assuming the modules are your own, you
  Ville-Pertti> can name your record fields so that opening both
  Ville-Pertti> modules doesn't cause conflicts (e.g. using a short
  Ville-Pertti> prefix).

That's very kludgy, isn't it ?  I'm assuming the right way is to use
modules, which is what started this whole exercise for me.


  >> let (a:Foo.t) =  {n1=1; n2=2; a=(- 1.0)} in
  >> 
  >> Unbound record field label n1
  >> 
  >> After careful review of the grammar I discovered that is incorrect,
  >> although it seems like it should work.

  Ville-Pertti> Nothing about "a" affects the meaning of the
  Ville-Pertti> expression on the right hand side of the "=".

  Ville-Pertti> Even if it did, the visibility of identifiers is
  Ville-Pertti> determined only by lexical scope, typing has no
  Ville-Pertti> effect, which is why even if you have "a:Foo.t" in
  Ville-Pertti> scope, you can't access "a.n1".

Oh yes.  That makes makes sense.

Thanks for your help.

Brian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2004-05-11 16:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-11  5:13 briand
2004-05-11  7:32 ` Ville-Pertti Keinonen
2004-05-11 16:10   ` briand [this message]
2004-05-11 17:46     ` brogoff
2004-05-11 18:15       ` briand

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=16544.64275.204812.673065@soggy.deldotd.com \
    --to=briand@aracnet.com \
    --cc=caml-list@inria.fr \
    --cc=will@exomi.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).