caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] illegal permutation of structure fields?
@ 2001-07-23 13:04 Markus Mottl
  2001-07-23 15:27 ` Xavier Leroy
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Mottl @ 2001-07-23 13:04 UTC (permalink / raw)
  To: OCAML

Hello,

I've just found out to my surprise that the following does not work:

file: bla.ml
---------------------------------------------------------------------------
module type FOO = sig
  val x : int
  val y : int
end
---------------------------------------------------------------------------

file: bla.mli
---------------------------------------------------------------------------
module type FOO = sig
  val y : int
  val x : int
end
---------------------------------------------------------------------------

This yields the following error:

  The implementation bla.ml does not match the interface bla.cmi:
  Module type declarations do not match:
    module type FOO = sig val x : int val y : int end
  is not included in
    module type FOO = sig val y : int val x : int end
  Illegal permutation of structure fields

Why is this illegal? Wouldn't it be very straightforward to normalize
the signatures (e.g. sort elements by name) before matching them?

I knew that there is a somewhat similar restriction for record types,
which does not allow permutation of record elements in the type
definitions of implementation and interface.

In the latter case I see that without normalization there would be
problems correctly accessing record elements, but I don't quite understand
the rationale behind the first restriction.

Wouldn't normalization get rid of the problems in both cases? Or am I
overlooking anything?

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-07-26  8:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-23 13:04 [Caml-list] illegal permutation of structure fields? Markus Mottl
2001-07-23 15:27 ` Xavier Leroy
2001-07-23 16:07   ` Andreas Rossberg
2001-07-26  7:14     ` Xavier Leroy
2001-07-26  8:42       ` Markus Mottl
2001-07-23 16:36   ` Markus Mottl
2001-07-25 22:27   ` John Max Skaller

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).