Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] Custom operators in the revised syntax
On 5/11/07, Loup Vaillant <loup.vaillant@gmail.com> wrote:
> 2007/5/11, dmitry grebeniuk <gds-mlsts@moldavcable.com>:
> > Shalom, Nicolas.
> >
> > NP> Today it's about custom operators. In the original syntax everyone
> > NP> knows that's easy to define and use custom operators like ++, -->,
> > >>>>, +|, =?=, ... and as many as you want.
> >
> >   As for me, the lack of custom infix operators in revised syntax
> > is a feature that allows to keep code clean, without any
> > "=?=" or "<<+".  The code "(func arg1 arg2)" is imho much
> > more readable than "arg1 op arg2" because: 1. function name
> > usually says something about the meaning of the function, 2. you
> > don't need to remember operator's precedence and associativity
> > to understand the code.
>
> I remember a family of languages where (func x y) is the only syntax : Lisp. :)
>
> I tend to agree when one says custom operators are evil. However, when
> the default syntax uses operators, the custom ones are a net win : a
> wise programmer will use their semantic load carefully (big nums, for
> example), and sparsely, so the code is more readable.  An unwise
> programmer will make the code unreadable anyway, regardless of the
> operators.

One always can write unreadable code, no? So it's more a matter of how
much using these features than having them.

BTW the really cool thing about how custom operators are treated in
OCaml is the fact that their understanding do not depend on the
definition of them.

If you know the parsing rules of + then you know those for +|%@!^&++?@^

-- 
Nicolas Pouillard