From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA17319 for caml-redistribution; Tue, 22 Feb 2000 11:46:22 +0100 (MET) 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 UAA31515 for ; Mon, 21 Feb 2000 20:31:36 +0100 (MET) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA15789 for ; Mon, 21 Feb 2000 20:31:34 +0100 (MET) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id UAA03460; Mon, 21 Feb 2000 20:31:07 +0100 (MET) From: Markus Mottl Message-Id: <200002211931.UAA03460@miss.wu-wien.ac.at> Subject: Re: Dichotomy between functions and type constructors? To: dmcclain@azstarnet.com (David McClain) Date: Mon, 21 Feb 2000 20:31:07 +0100 (MET) Cc: caml-list@inria.fr (OCAML) In-Reply-To: <000501bf7a51$60490100$250148bf@vega> from "David McClain" at Feb 18, 2000 01:47:28 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: weis > Say I have a type > > T1 of int * float > I can create such a type as T1(5, 3.14) but I cannot create such a type on a > tuple result of a function call: > > let doit x = (x, float_of_int x) > > let myT1 = T1(doit x) This is a trap into which I have already fallen when I tried to find a bug in a C-interface. Xavier explained the "problem" to me when I sent a bug report, because I had thought that the source of the error originated in OCaml: type t = T1 of int * float is *not* the same as: type t = T1 of (int * float) The first one is an example of a dataconstructor that takes two arguments (an int and a float), whereas the second one is a dataconstructor that takes *one* argument which happens to be a tuple... So this, for example, works: type t = T1 of (int * float) let doit x = (x, float_of_int x) let myT1 x = T1(doit x) I haven't taken a look at the FAQs, whether this misunderstanding is already explained there. In any case, it should be mentioned somewhere, because it is a somewhat surprising fact (if you haven't seen it before). It is especially difficult to find the bug if you create data in C the wrong way and wonder why the program keeps crashing: in contrast to the multi-argument case the tuple case is represented internally with an indirection... Best regards, Markus Mottl -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl