caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus@mail4.ai.univie.ac.at>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: Markus Mottl <markus@mail4.ai.univie.ac.at>, OCAML <caml-list@inria.fr>
Subject: Re: [Caml-list] illegal permutation of structure fields?
Date: Mon, 23 Jul 2001 18:36:18 +0200	[thread overview]
Message-ID: <20010723183618.B24670@fichte.ai.univie.ac.at> (raw)
In-Reply-To: <20010723172755.A5259@pauillac.inria.fr>; from Xavier.Leroy@inria.fr on Mon, Jul 23, 2001 at 17:27:55 +0200

Hm, well, thanks a lot for the very elaborate explanation! ... But I am
still not fully convinced (evil me! ;)

On Mon, 23 Jul 2001, Xavier Leroy wrote:
> 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

Why doesn't the normalized inferred signature of the module determine
its layout? E.g.:

  module A = struct
    let y = 1
    let x = 2
  end

could be transformed to (tuple that describes memory layout):

  (2, 1)

Of course, one would have to make sure that side effects are executed
in the right order when the creation of the values involves any, but
this should only require sorting the computations accordingly. This
marginally complicates things, but ...

> When you perform signature matching, the compiler recomputes the
> structure representation to match the new signature.  For instance:
> 
>   module C : sig val y : int val x : int end = A
> 
> causes the compiler to generate roughly the following code
> 
>   let C = (snd A, fst A)

... such glue code wouldn't be necessary in this case anymore: the
compiler could just generate:

  let C = A

Of course, if the signature of C were more restrictive than A, we might
have to generate a fresh tuple again, because some tuple slots could
disappear.

> so that the representation of C matches what clients of C expect from
> its signature.

The client would always expect the order of the normalized signature,
which should make it match the order used in the implementation, which
is also normalized.

> If we were to allow module type equivalence up to permutation, this
> strategy would be invalid.  Consider:

[snip]

The snipped example wouldn't lead to any problems with the mentioned
approach where the module implementation is already in normalized order.

> However, I believe there are more complex examples involving abstract
> module types (e.g. as functor parameters) where expanding module type
> names would not suffice.  So, let's keep it simple: no permutation!

I don't see any inherent problem here, but maybe I just don't fully
understand your argument. Am I missing some hidden catch?

Anyway, I don't feel terribly restricted without permutation, and not
having to rearrange the elements of the tuple on some simple module
equations doesn't look like a big performance gain either. So even if
my idea worked, I wouldn't mind if you put them on your "superfluous
features"-staple... ;)

Best 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


  parent reply	other threads:[~2001-07-23 16:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-23 13:04 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 [this message]
2001-07-25 22:27   ` John Max Skaller

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=20010723183618.B24670@fichte.ai.univie.ac.at \
    --to=markus@mail4.ai.univie.ac.at \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@inria.fr \
    /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).