From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 05EB3BC69 for ; Thu, 8 Mar 2007 21:34:09 +0100 (CET) Received: from hedwig1.umh.ac.be (hedwig2.umh.ac.be [193.190.193.73]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l28KY8cE031618 for ; Thu, 8 Mar 2007 21:34:08 +0100 Received: from poincare.swapping.umh.ac.be ([10.102.100.10]) by hedwig1.umh.ac.be (8.13.6/8.13.6) with ESMTP id l28KaTgl4808882; Thu, 8 Mar 2007 21:36:29 +0100 Received: from localhost ([127.0.0.1] ident=trch) by poincare.swapping.umh.ac.be with esmtp (Exim 4.63) (envelope-from ) id 1HPPJP-00045f-6k; Thu, 08 Mar 2007 21:34:07 +0100 Date: Thu, 08 Mar 2007 21:34:07 +0100 (CET) Message-Id: <20070308.213407.67921622.Christophe.Troestler+ocaml@umh.ac.be> To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Interactive technical computing From: Christophe TROESTLER In-Reply-To: <200703081934.07403.jon@ffconsultancy.com> References: <1173356534.8655.6.camel@localhost.localdomain> <20070308.152439.98695201.Christophe.Troestler+ocaml@umh.ac.be> <200703081934.07403.jon@ffconsultancy.com> X-Face: #2fb%mPx>rRL@4ff~TVgZ"<[:,oL"`TUEGK/[8/qb58~C>jR(x4A+v/n)7BgpEtIph_neoLKJBq0JBY9:}8v|j Organization: University of Mons-Hainaut X-Mailer: Mew version 5.1.52 on Emacs 22.0.95 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.1 (www dot roaringpenguin dot com slash mimedefang) X-Miltered: at concorde with ID 45F07340.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; christophe:01 troestler:01 christophe:01 troestler:01 ocaml:01 umh:01 inference:01 camlp:01 hackery:01 lacaml:01 bigarray:01 elt:01 bigarray:01 val:01 val:01 On Thu, 8 Mar 2007, Jon Harrop wrote: > > I can't justify the time unless I get to sell something. :-) I understand that, that why I put Gerd's quote first. > I don't think you can obtain F#'s brevity/clarity that way because > you need to affect type inference and macros can't do that. No but macros can locally change what '+' means. With some Camlp4 hackery and using the Vec.t type of Lacaml (which is a shorthand for (float, Bigarray.float64_elt, Bigarray.fortran_layout) Bigarray.Array1.t), your F# example could look : # let a = {| 1.; 2.; 3. |} and b = {| 2.; 3.; 4. |};; val a : Vec.t = {| 1.; 2.; 3. |} val b : Vec.t = {| 2.; 3.; 4. |} # Vec.(a + b);; - : Vec.t = {| 3.; 5.; 7. |} Of course, when mixing vectors and matrices, we will not be able to stay with only + and * but I am not sure that having to put type annotations will compare favorably to put the expression in Mat.(...) and inventing a _few_ additional operators. Moreover I think that, in some respects, it is even better than overloading! For example if you write # Vec.(a + b + c) then Camlp4 could generate code that only needs to create 1 temporary vector to hold the result instead of 2 (as is the case in F#). Cheers, ChriS