From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q3R6vtUX029471 for ; Fri, 27 Apr 2012 08:57:55 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0BALFCmk/RVdK2kWdsb2JhbABFn22SAggiAQEBAQkJDQcSKYIJAQEBAwESAiwBGxILAQMBCwYFCwMKDSEiAREBBQEKEgYTEgkHh1wBAwYFC51ACowjgnOFGQoZJwMKV4h2AQULkTgElX2BEY1PPYQN X-IronPort-AV: E=Sophos;i="4.75,489,1330902000"; d="scan'208";a="141802413" Received: from mail-iy0-f182.google.com ([209.85.210.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 Apr 2012 08:57:50 +0200 Received: by iahk25 with SMTP id k25so1058944iah.27 for ; Thu, 26 Apr 2012 23:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=ZP3PH/xz2nZJi05O5ZR5DVqN4Voh5/HulDjtNWmvuSE=; b=z9sMEhv3FVYYjUVQ8fsQjs5NIpAFGOqQDTiJRP5UyBjuZG6DpbL/2XQYl2/CN+vrGC TwwaAJNeInPO4AZ9DPoYXWzrlRcjlWMN5Kbzh6vKDD8TYuHBPCCKLu1R9fPrPTuv6dUV 1EOAX6A5/7z9Nngb5sQOgaTwjfYYcG8KWNcZuCkuKAUtsNHHDXfEV8QYUym/w/OVCvW3 btdnIZaN5X+gpTMQKuBk3zsuqzeZShrRhiju5JZwtl5naerGiHtEm6ttt+caKpP8Scze cnyp2MF9s6I9Qqbd/IFO2wE+j7HyRyHMqByqugyiTw+GsL8kn0ba2CP8tyBmQN9fQdKg 1YaQ== Received: by 10.50.217.164 with SMTP id oz4mr796688igc.70.1335509868667; Thu, 26 Apr 2012 23:57:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.140.100 with HTTP; Thu, 26 Apr 2012 23:57:08 -0700 (PDT) In-Reply-To: <3C0F509D-8590-4D45-A586-83630088C7B5@pobox.com> References: <3C0F509D-8590-4D45-A586-83630088C7B5@pobox.com> From: Gabriel Scherer Date: Fri, 27 Apr 2012 08:57:08 +0200 Message-ID: To: Haoyang Wang Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q3R6vtUX029471 Subject: Re: [Caml-list] using infix operators/functions in modules when not using "open" > Module.("foo" (op) "bar") This is a local open (a more explicit notation is "let open Module in foo op bar"). I think this is a fine solution: I don't like open, but local mitigates its flaws. Another solution is to rebind your operator locally: let (op) = Module.blah in "foo" op "bar" (of course Module.blah doesn't need to be an infix itself) If you are going to use an infix operator in a wide scope, I think that such a rebinding solution is nice because it's more explicit, which is good when it helps users understand the code. On Fri, Apr 27, 2012 at 1:01 AM, Haoyang Wang wrote: > > On Apr 26, 2012, at 3:36 PM, ocamllist.robertwork@spamgourmet.com wrote: > >> I'm a OCaml newbie.  I don't understand how to use infix functions that are in modules when I don't want to use "open". >> >> I did discover http://xahlee.org/ocaml/functions.html which explains that an infix operator can be used as a prefix.  So, this format: >> >>   ((Module.(op)) "foo" "bar") >> >> does seem to work.  But, intuitively, it seems like: >> >>  "foo" Module.(op) "bar" >> >> would work -- it doesn't. >> >> Is there a way to keep the infix notation? >> >> Thanks. > > > Module.("foo" (op) "bar") > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >