caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: "Loup Vaillant" <loup.vaillant@gmail.com>
Cc: "Caml List" <caml-list@inria.fr>,
	"Gerard Huet" <Gerard.Huet@inria.fr>,
	"Benoit Razet" <Benoit.Razet@inria.fr>
Subject: Re: [Caml-list] Custom operators in the revised syntax
Date: Fri, 11 May 2007 00:25:17 +0200	[thread overview]
Message-ID: <cd67f63a0705101525h3e5351bfn7b9ea51f8de06d2@mail.gmail.com> (raw)
In-Reply-To: <6f9f8f4a0705101435g48fa4959ia55e6411c966fc17@mail.gmail.com>

On 5/10/07, Loup Vaillant <loup.vaillant@gmail.com> wrote:
> 2007/5/10, Nicolas Pouillard <nicolas.pouillard@gmail.com>:
> > Hello,
> >
> > Again this message is about the revised syntax and it's negative
> > points or useless distances with the original one.
> >
> > Today it's about custom operators. In the original syntax everyone
> > knows that's easy to define and use custom operators like ++, -->,
> > >>>, +|, =?=, ... and as many as you want.
> >
> > To declare them in the original syntax one needs parens:
> >
> > let ( =?= ) x y = ...;;
> >
> > In the revised syntax one use a backslash:
> >
> > value \=?= x y = ...;
> >
> > Why not... but in the revised syntax these new operators are not
> > automatically infix or prefix or postfix, you have to make your own
> > syntax extension. In practice I found it too heavy, unless you already
> > have a custom syntax extension local to the project or something like
> > that.
>
> I regret that a bit too. However, I can't tell I really miss it: I
> find the default prefix syntax for function terse enough, so I don't
> bother. The only useful usage I can think about is associative
> operators, with which one can fold many arguments at once.
>
> For example, the function composition :
> (f (g (h (i x)))) becomes (f ° g ° h ° i) x
> wich looks a bit better.

Exactly.

> > However there is bad things with parens:
> >
> > - Not LL(1) when treating them in parsing
> > - Spaces must be used for the `*' character to avoids starting comments.
> >
> > In fact when dealing them in the lexer that's ok.
> > And the space issue is not too big.
> >
> > Concerning the fixity of these operators I've already changed it to
> > have the same thing as the original syntax.
>
> By the way, which are the fixity and associativity of custom operators
> in the original syntax?

In fact the cool thing is that the rule is really simple, long
operators have the same associativity, fixity, priority as the well
known prefix of it.

Example:

+| is like + (infix, left assoc...)

<=> is like <

!* is like ! (prefix)

**/ is like ** (infix, right assoc)

Simple no?

> > Concerning the backslash, I want to restore the parens convention to
> > declare them and then free the backslash character and make it
> > available in the default lexer (useful for an ascii lambda for
> > instance).
>
> Err, I may not understand, but isn't "fun" terse enough? Or is it just
> an idea from Haskell?

I'm not talking about the revised syntax itself but about the reusable
camlp4 lexer, in case of using the camlp4 parsing system. If one want
to parse a language with lambdas as backslashs (like Haskell and
others one can do it).

I think also about operators like \/ for OR and /\ for AND.

> > As before, feel free to make comments on that (not really passionating) subject.
>
> It should be : adding up "not really passionating" upgrades may lead
> to a quiet revolution, eventually. :)
:)

-- 
Nicolas Pouillard

  reply	other threads:[~2007-05-10 22:25 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-10 20:55 Nicolas Pouillard
2007-05-10 21:35 ` [Caml-list] " Loup Vaillant
2007-05-10 22:25   ` Nicolas Pouillard [this message]
2007-05-11  6:52 ` Stefano Zacchiroli
2007-05-11 13:14 ` dmitry grebeniuk
2007-05-11 14:15   ` Loup Vaillant
2007-05-11 14:37     ` Jon Harrop
2007-05-11 14:46       ` Nicolas Pouillard
2007-05-12  2:48         ` Jon Harrop
2007-05-12  4:40           ` skaller
2007-05-12  4:47             ` Jon Harrop
2007-05-12  5:45               ` skaller
2007-05-12  5:59                 ` Jon Harrop
2007-05-12  6:43                   ` skaller
2007-05-12 10:22             ` Richard Jones
2007-05-13 15:42               ` Arnaud Spiwack
2007-05-13 16:04                 ` ls-ocaml-developer-2006
2007-05-13 20:08                   ` Nicolas Pouillard
2007-05-12  9:49           ` Nicolas Pouillard
2007-05-12 10:09             ` Jon Harrop
2007-05-11 14:52       ` Loup Vaillant
2007-05-11 18:32         ` skaller
2007-05-12  4:48         ` Jon Harrop
2007-05-11 18:23       ` skaller
2007-05-11 14:40     ` Nicolas Pouillard
2007-05-11 18:22     ` skaller
2007-05-11 14:36   ` Nicolas Pouillard
2007-05-11 14:47     ` brogoff
2007-05-11 14:51       ` Nicolas Pouillard
2007-05-11 18:25         ` brogoff
2007-05-11 20:37           ` Nicolas Pouillard
2007-05-12 22:54           ` Nicolas Pouillard
2007-05-13  0:27             ` ketti
2007-05-13  1:05               ` Christian Stork
2007-05-13 10:50                 ` Nicolas Pouillard
2007-05-13  5:52             ` brogoff
2007-05-13  7:36               ` skaller
2007-05-13 13:12                 ` Jacques Carette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd67f63a0705101525h3e5351bfn7b9ea51f8de06d2@mail.gmail.com \
    --to=nicolas.pouillard@gmail.com \
    --cc=Benoit.Razet@inria.fr \
    --cc=Gerard.Huet@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=loup.vaillant@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).