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
environment idiom
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-11 (23:29)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] environment idiom
On Sun, 2004-12-12 at 01:31, Andrej Bauer wrote:
> It seems that John Skaller and I have different experiences, 

Yes but I came to almost the same conclusion as you.
I agree with your basic premise, I propose only a
minor amendment, possibly more suitable for

> He offers a C/C++ example of the
> const pointers. I am not convinced that ocaml and C/C++ are comparable
> in this respect. 

The principle is quite general, exceeding not only C++/Ocaml,
but applying way beyond programming.  I actually learned
this idea, that one should think about how a code base
will cope with change, in a superb book on Cobol programming.
More recently, Bertrand Meyer stated the Open/Closed principle,
which deals with a related issue.

As an example: this code is fragile:

	for(int i =0; i!=10; ++i)a[i]=b[i];

because it terminates *precisly* at the expected
array length. It will fail for any change in array length.

Fragile coding is good sometimes, and other times you
would prefer your code to be robust. To some extent it
depends on the use of your code and how much money you have
to finish the program. For a quick and dirty program,
you'd make it robust. If it's a library that is intended
to be heavily used, you make it fragile.

> I habitually abuse the ocaml compiler to tell me
> precisely what needs to be changed in the following way: I change a type
> or value definition (say, change the arguments to a function) and keep
> running the compiler until it reports errors, fixing them as they come
> up. 

I do that too. Heavily. Only I don't think of it as abuse :)

Unfortunately some things in a compiler seem to demand
run time checks where you'd much prefer static typing.
However the strongest static typing is very hard to get
exactly right, and is quite verbose. I'd spend more
time fiddling with it when things changed, than modifying
the algorithms which actually do the work.

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language