Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] petty complaints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David McClain <dmcclain1@m...>
Subject: Re: [Caml-list] petty complaints
> Haskell allows to
> use any identifier as a binary operator when it is placed in
> backquotes:  x `plus` y.  These operators are often more readable than
> the classic infix operator symbols.  These terms have no associativity
> and a low precedence, thus forcing to use parentheses.  An
> implementation would only affect the lexer and should not be too hard.
> Would other people like this feature, too?

Yes, indeed! I have implemented this in my NML which is a very simple
language in comparison to OCaml, but it borrowed the OCaml Lex and Yacc as
starting points. It was very easy to implement this feature and I tend to
use it most often with integer divide, modulo, and the bit twiddling
primitives, as in

    let x = y `mod` z in ...

I also have a syntax for list and vector comprehensions, a la Haskell. Very
convenient for terse programming, e.g.,

    let x = [(a,b) |: a <- [1 .. 100], b <- 100 - a] in ...

- DM

----- Original Message -----
From: "Christian Lindig" <lindig@eecs.harvard.edu>
To: "Caml Mailing List" <caml-list@inria.fr>
Sent: Monday, April 09, 2001 8:34 AM
Subject: Re: [Caml-list] petty complaints


> On Sun, Apr 01, 2001 at 09:26:59PM -0700, Brian Rogoff wrote:
> >     Another unrelated trifling question concerns the syntax of numerical
> > literals.
>
> Now that the spring cleaning for OCaml's syntax (floats, labels,
> constructors) is in full swing, here is my wish:  Haskell allows to
> use any identifier as a binary operator when it is placed in
> backquotes:  x `plus` y.  These operators are often more readable than
> the classic infix operator symbols.  These terms have no associativity
> and a low precedence, thus forcing to use parentheses.  An
> implementation would only affect the lexer and should not be too hard.
> Would other people like this feature, too?
>
> -- Christian
>
> --
> Christian Lindig          Harvard University - DEAS
> lindig@eecs.harvard.edu   33 Oxford St, MD 242, Cambridge MA 02138
> phone: +1 (617) 496-7157  http://www.eecs.harvard.edu/~lindig/
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr.  Archives:
http://caml.inria.fr

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr