Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[OSR] Standard syntax extensions ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-04-26 (21:32)
From: Arthur Chan <baguasquirrel@g...>
Subject: Re: [Caml-list] [OSR] Standard syntax extensions ?
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

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 <> 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.