From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA24993 for caml-redistribution; Wed, 21 May 1997 15:04:29 +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 MAA22990 for ; Wed, 21 May 1997 12:50:36 +0200 (MET DST) Received: from heaton.cl.cam.ac.uk (exim@heaton.cl.cam.ac.uk [128.232.32.11]) by nez-perce.inria.fr (8.8.5/8.7.3) with SMTP id MAA06623 for ; Wed, 21 May 1997 12:50:33 +0200 (MET DST) Received: from cl.cam.ac.uk [128.232.0.129] (jrh) by heaton.cl.cam.ac.uk with esmtp (Exim 1.59 #2) id 0wU8yQ-0008Ks-00; Wed, 21 May 1997 11:50:26 +0100 X-uri: To: caml-list@inria.fr cc: John.Harrison@cl.cam.ac.uk Subject: Re: arity of type constructors In-reply-to: Your message of "Thu, 08 May 1997 22:15:23 +0200." Date: Wed, 21 May 1997 11:50:23 +0100 From: John Harrison Message-Id: Sender: weis David Monniaux writes: | If you declare type t = T of int*int, it declares a type t whose only | constructor takes two parameters, of respective types int and int, not a | constructor that takes one paramete of type int*int. Thus it can't be | applied to a pair. | | That is reflected in the way memory objects are handled. A constructor | that takes a pair as an argument will have the following layout: | | T -> pair [ int | [ int | | if it has two arguments, the layout is the following: | | T [ int | [ int | | Using a pair adds one level of indirection. In that case, what happens during pattern-matching? For example: > Caml Light version 0.73 #type triv = Triv of int*int;; Type triv defined. #let getpair = fun (Triv(p)) -> p;; getpair : triv -> int * int = Is this sort of definition safe? Perhaps one should use the following to ensure a pair is reconstructed: #let getpair = fun (Triv(a,b)) -> a,b;; John.