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=HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 98290BBCA for ; Sat, 26 Apr 2008 23:32:27 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqkCAC48E0jRVYC+c2dsb2JhbACCNTaObgEMAwQECQ8Fk0aEMg X-IronPort-AV: E=Sophos;i="4.25,712,1199660400"; d="scan'208";a="25547778" Received: from fk-out-0910.google.com ([209.85.128.190]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Apr 2008 23:32:27 +0200 Received: by fk-out-0910.google.com with SMTP id b27so6850959fka.11 for ; Sat, 26 Apr 2008 14:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=a6a/w9ElzeBXhh6p1Fj8r84cuH6gVCrUMtooIs3yUf4=; b=Qga234ojDAZR7hNW2vnPTqVlByot0uojuXSQp5v34/a3ACUbswHJC5wyAoC1TafrCFTtvxWQgMkvrfo+7/VZa1OiMcI1bFPmNa2QBlfnUxIcnvVUq/J0yc7yg4yQKdCnCxUdKTG04tb8nVTj2GxJ/E0Hc4ODP0dIO95vf344j+Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=PHdrEw9GiOlqKw7MRfXNYbWeVGPd+2DHkTiHU7HXlEaDIV34/SDIWuU6y4L3mel6yrU3JNx36c1pXGZIPZh07647Nj5emulYIfuF2g/DnCbcRfkK6XT7bGD+rqYghWdDKRr+ZUWaWMXSffT1fcv5PHO87OAu5a4+bLBaSCJdTRI= Received: by 10.78.143.13 with SMTP id q13mr39781hud.80.1209245546286; Sat, 26 Apr 2008 14:32:26 -0700 (PDT) Received: by 10.78.187.19 with HTTP; Sat, 26 Apr 2008 14:32:26 -0700 (PDT) Message-ID: <74cabd9e0804261432o116f4db5w2f5777496da17d94@mail.gmail.com> Date: Sat, 26 Apr 2008 14:32:26 -0700 From: "Arthur Chan" To: "Till Crueger" Subject: Re: [Caml-list] [OSR] Standard syntax extensions ? Cc: "Richard Jones" , Caml , "David Teller" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1294_24873825.1209245546285" References: <1209052182.6180.35.camel@Blefuscu> <74cabd9e0804251337m40811532yb359710630cdbdfd@mail.gmail.com> <20080426074157.GA15640@annexia.org> X-Spam: no; 0.00; syntax:01 infix:01 syntax:01 ocaml:01 infix:01 corresponds:01 notation:01 notation:01 type-safe:01 0200,:01 'list:01 haskell:01 ocaml:01 elegantly:01 corresponds:01 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_1294_24873825.1209245546285 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline As Till Crueger suggested, sometimes the infix syntax makes more sense. More than that, one of the intents of the original ML language was to create a language that was clear in its intents and *provably correct* (at least that was what I was taught in school. ocaml apparently isn't completely provably correct but the functional parts of it are). That said, there are some of us who feel that that the python infix syntax is clearer, and as it corresponds more directly to the mathematical notation, it is just as provably correct as the List.mem notation is. If reusing "in" is a big deal, then maybe we could do "in_list" or "inlist"? That'd be more type-safe too. The python syntax goes further than just the "in" bit, in fact. They can do list comprehensions like [for x in blah if f(x)]. Now every functional guru will recognize this immediately as the bastardization of List.filter. While it'd be nice to have that, I come across List.filter much less than List.exists/mem. Whatever.... it's just a minor quibble, but this thread was about syntax extensions, after all. On Sat, Apr 26, 2008 at 12:53 AM, Till Crueger < crueger@informatik.uni-bonn.de> wrote: > On Sat, 26 Apr 2008 09:41:57 +0200, Richard Jones > wrote: > > I'm guessing that there will be ambiguity because you're wanting to > > add yet another meaning to the reserved word 'in'. > > > > However I'm not sure why you don't just use 'List.mem', or even: > > > > let mem = List.mem ;; > > > > mem 1 [1;2;3] > > > > Since I am reading the "Haskell School of expressions" right now (to > become better at functional Programming, not to leave my favourite language > :)) I am starting to like the way you can turn any function into an infix > operator by using quotes. Wouldn't it be possible to have something similar > to this in OCaml? I don't think there is an easy way to do this yet, since I > didn't find anything on this topic. > > I am posting this in this thread, because this would allow us to write the > above more elegantly as: > 1 `mem` [1;2;3], which is close to what was originally proposed. > > What do you think of this? > > bye, > Till > > > -- > There once was a man from the sticks > Who liked to compose limericks. > But he failed at the sport, > For he wrote 'em too short. > -- ----------------------------------------------------------------------- (\__/) (='.'=)This is Bunny. Copy and paste Bunny into your (")_(")signature to help him gain world domination. ------------------------------------------------------------------------ ------=_Part_1294_24873825.1209245546285 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline As Till Crueger suggested, sometimes the infix syntax makes more sense.  More than that, one of the intents of the original ML language was to create a language that was clear in its intents and *provably correct* (at least that was what I was taught in school.  ocaml apparently isn't completely provably correct but the functional parts of it are).  That said, there are some of us who feel that that the python infix syntax is clearer, and as it corresponds more directly to the mathematical notation, it is just as provably correct as the List.mem notation is.  If reusing "in" is a big deal, then maybe we could do "in_list" or "inlist"?  That'd be more type-safe too.

The python syntax goes further than just the "in" bit, in fact.  They can do list comprehensions like [for x in blah if f(x)].  Now every functional guru will recognize this immediately as the bastardization of List.filter.  While it'd be nice to have that, I come across List.filter much less than List.exists/mem.

Whatever....  it's just a minor quibble, but this thread was about syntax extensions, after all.




On Sat, Apr 26, 2008 at 12:53 AM, Till Crueger <crueger@informatik.uni-bonn.de> wrote:
On Sat, 26 Apr 2008 09:41:57 +0200, Richard Jones <rich@annexia.org> wrote:

I'm guessing that there will be ambiguity because you're wanting to
add yet another meaning to the reserved word 'in'.

However I'm not sure why you don't just use 'List.mem', or even:

 let mem = List.mem ;;

 mem 1 [1;2;3]

Since I am reading the "Haskell School of expressions" right now (to become better at functional Programming, not to leave my favourite language :)) I am starting to like the way you can turn any function into an infix operator by using quotes. Wouldn't it be possible to have something similar to this in OCaml? I don't think there is an easy way to do this yet, since I didn't find anything on this topic.

I am posting this in this thread, because this would allow us to write the above more elegantly as:
1 `mem` [1;2;3], which is close to what was originally proposed.

What do you think of this?

bye,
 Till


--
There once was a man from the sticks
Who liked to compose limericks.
But he failed at the sport,
For he wrote 'em too short.



--
-----------------------------------------------------------------------
(\__/)
(='.'=)This is Bunny. Copy and paste Bunny into your
(")_(")signature to help him gain world domination.
------------------------------------------------------------------------ ------=_Part_1294_24873825.1209245546285--