caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: rossberg@ps.uni-sb.de
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Records typing
Date: Wed, 13 Nov 2002 10:11:31 +0900	[thread overview]
Message-ID: <20021113101131D.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <3DCF97ED.6E81EB98@ps.uni-sb.de>

From: Andreas Rossberg <rossberg@ps.uni-sb.de>
> malc wrote:
> > 
> > # module type T = sig type t type r = { f : t } end;;
> > module type T = sig type t and r = { f : t; }  end
> > 
> > # module M : T with type t = float = struct
> >   type t = float
> >   type r = { f : t }
> > end;;
> > 
> > Signature mismatch: ...
> > 
> > Is there a way to work around this?
> 
> This seems to be a bug. You can work around it using "and" to connect
> the type declarations in the structure:
> 
> # module type T = sig type t type r = { f : t } end;;
> module type T = sig type t and r = { f : t; }  end
> # module M : T with type t = float = struct
>   type t = float
>   and r = { f : t }
> end;;
> module M : sig type t = float and r = { f : t; }  end

Actually this is not a bug. And your workaround is very interesting
(and useful).
The fact is, the two definitions are actually semantically different
(at least from the point of view of the compiler).

% ocaml -dlambda
        Objective Caml version 3.06+16 (2002-11-04)

# module M = struct type t = float and r = {f:t} end;;
module M : sig type t = float and r = { f : t; }  end
# {M.f = 1.0};;
[0: 1.0]
- : M.r = {M.f = 1.}
# module M' = struct type t = float type r = {f : t} end;;
module M' : sig type t = float and r = { f : t; }  end
# {M'.f = 1.0};;
[|1.0|]
- : M'.r = {M'.f = 1.}

In the first case, the record is represented as an array of a pointer
to a boxed float, while in the second case it is represented as an
array of an unboxed float. Since the data representation is different,
these two signatures are not equivalent. I was afraid there would be
no direct way to express the first case, but actually you can.

Jacques Garrigue
-------------------
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:[~2002-11-13  1:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-06 12:57 malc
2002-11-11 11:43 ` Andreas Rossberg
2002-11-13  1:11   ` Jacques Garrigue [this message]
2002-11-13  2:41     ` Jacques Garrigue
2002-11-13 14:48       ` Andreas Rossberg
2002-11-13  9:55     ` malc
2002-11-13 10:08       ` Jacques Garrigue
2002-10-24 10:55         ` Christophe Raffalli

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=20021113101131D.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=rossberg@ps.uni-sb.de \
    /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).