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 DAA03888 for caml-redistribution; Fri, 30 Jul 1999 03:26: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 UAA26998 for ; Wed, 28 Jul 1999 20:48:47 +0200 (MET DST) Received: from zeppo.csd.uu.se (zeppo.csd.uu.se [130.238.15.19]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA29036 for ; Wed, 28 Jul 1999 20:48:45 +0200 (MET DST) Received: (from jenso@localhost) by zeppo.csd.uu.se (8.8.5/8.8.5) id UAA24143; Wed, 28 Jul 1999 20:48:45 +0200 (MET DST) From: Jens Olsson MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-ID: <14239.20620.728265.612382@zeppo.csd.uu.se> Date: Wed, 28 Jul 1999 20:48:44 +0200 (MET DST) To: caml-list@inria.fr Subject: tuple vs curried, records vs variants X-Mailer: VM 6.61 under Emacs 19.34.1 Sender: weis Hello, (Yet another 'newbie'-question for anyone who has the patience) Different sources (such as the documentation) says curried functions are to prefer rather than functions using tuples, if speed is of any concern anyway. Before realizing this and as I'm used to the SML dialect, I implemented a module for three-dimensional vectors using 'tupled' functions first. Upon a question regarding speed I also got the recommendation to use records instead of a variant with a single constructor. After making all the functions curried instead, and changing the implementation to use records instead I measured the performance of the two implementation and realized to my surprise that the old version (the implementation using variants and tupled functions) was faster (than the one using records and curried functions). So my questions are: 1) Is this really correct? I tried the implementations on two different= architectures and got the same result. One can ask if the test progr= am wasn't 'good enough'. 2) Is it only a "religious" question to use single-valued variants instead of records (when defining a datatype) or has speed something= to do with it? If the former case applies, which one should I use and why? Any other aspects? 3) BTW, what is the "best" way of writing pattern-matching functions, ie [let f x = match ....] or [let f = function x -> ...]? (Maybe we're getting 'religious' here as well?) I guess my code is not of interest so I'll exclude it but if someone thinks it's relevant I can provide it. Thanks in advance for any response to my somewhat basic questions... best regards Jens -- --[ Jens Olsson ]----------------------------------------------------- [Address] [Phone] [WWW] Dj=E4knegatan 13, 1tr Home: 018 - 24 88 77 jenso@csd.uu.se = 754 23 Uppsala Work: 018 - 471 76 85 www.csd.uu.se/~jenso SWEDEN Cell: CEASED!!! ICQ UID 8955231 ---------------------------------[ CS student @ Uppsala University ]--