From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA07328; Mon, 23 Jul 2001 18:07:17 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA07420 for ; Mon, 23 Jul 2001 18:07:16 +0200 (MET DST) Received: from uni-sb.de (uni-sb.de [134.96.252.33]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f6NG7FL17821 for ; Mon, 23 Jul 2001 18:07:15 +0200 (MET DST) Received: from cs.uni-sb.de (cs.uni-sb.de [134.96.252.31]) by uni-sb.de (8.11.4/2001062800) with ESMTP id f6NG7FZ17545 for ; Mon, 23 Jul 2001 18:07:15 +0200 (CEST) Received: from mail.cs.uni-sb.de (mail.cs.uni-sb.de [134.96.254.200]) by cs.uni-sb.de (8.11.4/2001053000) with ESMTP id f6NG7EF17852 for ; Mon, 23 Jul 2001 18:07:14 +0200 (CEST) Received: from ps.uni-sb.de (grizzly.ps.uni-sb.de [134.96.186.68]) by mail.cs.uni-sb.de (8.11.4/2001062800) with ESMTP id f6NG7Df04772 for ; Mon, 23 Jul 2001 18:07:13 +0200 (CEST) X-Authentication-Warning: email: Host grizzly.ps.uni-sb.de [134.96.186.68] claimed to be ps.uni-sb.de Received: from ps.uni-sb.de (zoidberg.ps.uni-sb.de [134.96.186.121]) by ps.uni-sb.de (8.11.2/8.11.0) with ESMTP id f6NG7Ci13940; Mon, 23 Jul 2001 18:07:12 +0200 Message-ID: <3B5C4BB0.70D3B74B@ps.uni-sb.de> Date: Mon, 23 Jul 2001 18:07:12 +0200 From: Andreas Rossberg Organization: =?iso-8859-1?Q?Universit=E4t?= des Saarlandes X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: de, en MIME-Version: 1.0 To: OCAML Subject: Re: [Caml-list] illegal permutation of structure fields? References: <20010723150428.B12189@chopin.ai.univie.ac.at> <20010723172755.A5259@pauillac.inria.fr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Xavier Leroy wrote: > > > 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: > > 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? > > That's more or less what old versions of OCaml did, but it's > incorrect. The reason is that a module signature determine the layout > of the corresponding structure: if > > module A : sig val x : int val y : int end > > then A is represented as the tuple (value_of_x, value_of_y), while > > module B : sig val y : int val x : int end > > is represented as the tuple (value_of_y, value_of_x). Then the followup question of course is: isn't it trivial to use a canonical layout instead, where the tuple components are sorted wrt. to the corresponding fields' label? This way layout is invariant wrt permutation in signatures. Or is there a particular problem with such a scheme? (BTW, the same holds for record and variant types, where Ocaml does not allow reordering of fields/constructors either.) Best regards, - Andreas Rossberg -- Andreas Rossberg, rossberg@ps.uni-sb.de "Computer games don't affect kids. If Pac Man affected us as kids, we would all be running around in darkened rooms, munching pills, and listening to repetitive music." ------------------- 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