Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Question on language design (keywords vs Pervasives)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-08-20 (17:05)
From: Frank Atanassow <franka@c...>
Subject: Question on language design (keywords vs Pervasives)
Fermin Reig writes:
 > I'm curious about some interesting language design choices in ocaml
 > 3.0.
 > * "raise", "exn" are not keywords, but definitions in the Pervasives module.
 > This means that I can rebind them, [..elided..]
 > I can speculate that the intention is precisely that praogrammers be
 > able to rebind them at will, or maybe that it simplifies implementing
 > interpreters/compilers, but I don't know for sure. Could anyone
 > (preferably someone involved in the design) comment on the rationale
 > for these choices?

Maybe the ability to rebind was some small motivation, but I imagine the goal
of simplicity was the more significant factor. Why make "int" or "raise" a
keyword if you don't need to? Even if you rebind "int", say, functions
operating on the new "int" will not work on the old.

Conversely, if you made "int" or "raise" a keyword, why stop there? You could
also make a whole range of other notions special: reals, complex numbers,
associative maps, commands (procedures with types of the form A -> unit), file
I/O primitives, regular expressions, certain shell-related procedures... maybe
you can guess where I'm heading. :)

Of course, it's true OTOH that as keywords we could be slightly more confident
that we haven't made a mistake and overlooked some rebinding, but in practice
most people leave "int" and "raise" alone, or if they're rebound, then that's
done in another module and the fact that we're not talking about, say, is explicit in the fact that we call it "",

(BTW, I'm not involved with Ocaml.)

Frank Atanassow, Dept. of Computer Science, Utrecht University
Padualaan 14, PO Box 80.089, 3508 TB Utrecht, Netherlands
Tel +31 (030) 253-1012, Fax +31 (030) 251-3791