English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Custom operators in the revised syntax
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-05-10 (20:55)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Custom operators in the revised syntax

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

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.

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

As before, feel free to make comments on that (not really passionating) subject.


Nicolas Pouillard