caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] (int * int) <> int*int ?
Date: Thu, 23 Feb 2006 20:58:58 +0000	[thread overview]
Message-ID: <200602232058.59170.jon@ffconsultancy.com> (raw)
In-Reply-To: <006101c6389e$9bbbc440$1f570b50@mshome.net>

On Thursday 23 February 2006 17:28, Frédéric Gava wrote:
> is anybody can semantically explain why this 2 types are differents ?
>
> # type t=A of int*int and  t'= B of (int*int);;
> type t = A of int * int
> and t' = B of (int * int)

Only historical reasons, AFAIK. I do not believe this is necessary or that 
there is a logical reason for doing so.

> Morever I think that int*int=(int*int) in ML

Yes. I think it is logical to expect that.

> > And since the runtime representations are different, the types have to be
> > different.
>
> Wrong, you can the same representation but different types (e.g. int, char
> or many other examples)

I also believe that statement was wrong but I don't think you have provided 
counter-examples because the run-time representations are the same for the 
different types that you cite (rather than the converse).

Perhaps this is a better counterexample: the following functions "f" and "g" 
use different run-time representations but still have the same type:

# let f (a, b) = a+b
  let g (a, b as x) = a+b;;
val f : int * int -> int = <fun>
val g : int * int -> int = <fun>

camlT2__f_58:
.L100:
	lea	-1(%eax, %ebx), %eax
	ret
	.text
	.align	16
	.globl	camlT2__g_61
	.type	camlT2__g_61,@function
camlT2__g_61:
.L101:
	movl	4(%eax), %ebx
	movl	(%eax), %eax
	lea	-1(%eax, %ebx), %eax
	ret
	.text
	.align	16
	.globl	camlT2__entry
	.type	camlT2__entry,@function

I suspect a similar transformation could be done for variant type 
constructors.

Also, note that this behaviour does not appear with polymorphic variants, 
where int * int <=> (int * int):

# type t = A of int * int | B of (int * int);;
type t = A of int * int | B of (int * int)
# type t = [ `A of int * int | `B of (int * int) ];;
type t = [ `A of int * int | `B of int * int ]

I assume the arguments of a polymorphic variant are always boxed...

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


  parent reply	other threads:[~2006-02-23 21:18 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-23 17:28 Frédéric Gava
2006-02-23 18:33 ` [Caml-list] " Eric Cooper
2006-02-23 19:03   ` Martin Jambon
2006-02-23 19:07   ` Frédéric Gava
2006-02-23 20:15     ` Brian Hurt
2006-02-23 21:30       ` Frédéric Gava
2006-02-23 21:57         ` Brian Hurt
2006-02-23 22:30           ` Frédéric Gava
2006-02-23 22:50             ` Brian Hurt
2006-02-23 23:07               ` Frédéric Gava
2006-02-24  8:38     ` Alessandro Baretta
2006-02-24 12:59     ` Damien Doligez
2006-02-23 18:33 ` Thomas Fischbacher
2006-02-23 18:56 ` David Brown
2006-02-23 19:24   ` Frédéric Gava
2006-02-23 19:37   ` Frédéric Gava
2006-02-23 19:45     ` Frédéric Gava
2006-02-24  0:01       ` Jacques Garrigue
2006-02-24  0:18         ` Lukasz Stafiniak
2006-02-24  2:17           ` Jacques Garrigue
2006-02-24 13:07             ` Alain Frisch
2006-02-25 17:42               ` Vincent Balat
2006-02-25 18:30                 ` Nicolas Pouillard
2006-02-25 19:09                   ` Richard Jones
2006-03-01 12:48                     ` Nicolas Pouillard
2006-02-25 23:17                   ` Christophe TROESTLER
2006-03-01 13:01                     ` Nicolas Pouillard
2006-02-27 11:14                   ` camlp4 renovation [was: [Caml-list] (int * int) <> int*int ?] Hendrik Tews
2006-02-24 13:39             ` [Caml-list] (int * int) <> int*int ? Nicolas Cannasse
2006-02-24 14:49               ` Frédéric Gava
2006-02-24  8:27   ` also for tagged records? [Was: Re: [Caml-list] (int * int) <> int*int ?] Sebastian Egner
2006-02-24 14:01     ` Thomas Fischbacher
2006-02-23 20:58 ` Jon Harrop [this message]
2006-02-23 21:36   ` [Caml-list] (int * int) <> int*int ? Frédéric Gava

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=200602232058.59170.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.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).