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=none autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id F29DDBC0A for ; Mon, 14 May 2007 10:46:01 +0200 (CEST) Received: from moldavcable.com (moldavcable.com [89.187.37.10]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4E8k02h009227 for ; Mon, 14 May 2007 10:46:01 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by moldavcable.com (Postfix) with ESMTP id 6A4BB6B76B for ; Mon, 14 May 2007 11:45:41 +0300 (EEST) Received: from moldavcable.com ([127.0.0.1]) by localhost (mlc-gw-l.moldavcable.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14126-01 for ; Mon, 14 May 2007 11:45:36 +0300 (EEST) Received: from kas30pipe.localhost (localhost.localdomain [127.0.0.1]) by moldavcable.com (Postfix) with SMTP id C3B386B76C for ; Mon, 14 May 2007 11:45:34 +0300 (EEST) Received: from pm053.mlc.local (pm053 [192.168.50.53]) by moldavcable.com (Postfix) with ESMTP id 2FC146B76B for ; Mon, 14 May 2007 11:45:34 +0300 (EEST) Date: Mon, 14 May 2007 11:45:51 +0300 From: dmitry grebeniuk X-Mailer: The Bat! (v3.85.02) Home Organization: Moldavcable X-Priority: 3 (Normal) Message-ID: <010107921.20070514114551@moldavcable.com> To: Nicolas Pouillard Subject: Re[2]: [Caml-list] Custom operators in the revised syntax Resent-From: dmitry grebeniuk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Resent-Message-Id: <20070514084534.2FC146B76B@moldavcable.com> Resent-Date: Mon, 14 May 2007 11:45:34 +0300 (EEST) X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-SpamTest-Info: Not protected X-Virus-Scanned: by amavisd-new at moldavcable.com X-Miltered: at discorde with ID 464821C8.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; grebeniuk:01 syntax:01 foo:01 compositions:01 syntax:01 ambiguities:01 unreadable:01 infix:01 notation:01 perl's:01 ocaml:01 haskell:01 precedence:01 hoc:01 caml-list:01 Hello, Nicolas. >> > Something general like: x `foo` y ? >> Exactly. NP> I've a tiny patch to do that: NP> 2 ``List.mem`` [1;2;3] Sometimes it is very convenient (``map`` and function compositions are good examples). But I prefer syntax where one thing should be done in one way (that's why I prefer revised syntax -- lesser ambiguities than in original syntax). And the principle "there is more than one way to do it" is good for "weak" languages such as perl and bash and not for "strict" languages of ML family. I agree that "bad programmer will write unreadable code in any language/syntax", but it's better not to give to programmer any choices when it there is no need -- when the choice does not affect the result (for example, usually people don't need to think about whether they should write "fun .. -> .." or "function .. -> .."). And one more "against" point: using infix notation for functions allows to write "ad hoc"-code, which can grow enormously. In the original version of code there can be only "arg1 ``myfunc`` arg2", but it can grow to "(some complex expression1) ``some other things`` (some other expression)" over several lines. It can be compared to perl's "post-conditions": " if ". And, again, precedence and associativity: some people will want "a ``b`` c ``d`` e" to work as "(a ``b`` c) ``d`` e", some people -- as "a ``b`` (c ``d`` e)", and which interpretation is correct? The result of "1 ``(fun x y -> 2*x + 3*y)`` 2 + 3" will be 1*2+2*3+3 or 1*2+3*(2+3)? And every programmer must keep these things in the head to write and understand caml code. However, do anything you want, but please don't turn ocaml into perl, or, omg, haskell. -- WBR, dmitry mailto:gds-mlsts@moldavcable.com