Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Why are type functions postfix?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Why are type functions postfix?
> In OCAML and other ML dialects I've used, you say:
> 
>    let x: int ref = ref 3
> 
> Is there any reason that type functions like the first "ref" are
> postfix, unlike function application like the second "ref" that is
> prefix?

I think it's mostly historical: the original LCF ML used the postfix
syntax, and this syntax was kept in SML as well as in Caml.

When teaching this, I use to crack a joke that this syntax reflects
the british and american roots of the designers of ML: English lets
you say "an integer reference" instead of "a reference to an integer",
while, say, French would only allow the latter word ordering ("une
référence entière" or "une référence vers un entier").

But this folk explanation doesn't really hold: while also designed by
brits and americans, Haskell uses the prefix syntax for type
operators...

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners