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
[Caml-list] ANNOUNCE: mod_caml 1.0.6 - includes security patch
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-01-21 (19:29)
From: Max Kirillov <max630@m...>
Subject: Re: [Caml-list] ANNOUNCE: mod_caml 1.0.6 - includes security patch
On Tue, Jan 20, 2004 at 11:37:56AM -0800, David Brown wrote:
> The where clause works well for Haskell, because there are no order of
> evaluation issues.  Because of side-effects, the where clause in ocaml
> would usually just end up being confusing.  Think of a multi-page
> expression with a where clause at the end.  Not that this is good code,
> but it would sure be easy to miss.  It would probably cause the same
> kinds of problems that C's 'break' causes in switch statements.

If you want to make your code cryptic, no language feature (or
lack of one) can prevent you from that. "Where" construction is
a powerful way to make code more readable, placing it in "top to
bottom" style. You noted that placing actual computation in where block
can hinder the evaluation order. Then don't place the computation in
"where" block! Let's rewrite your example like this:

let _ = 
    let x = g () in
    f x
  where g () = ...

Here, no uncertainty about evaluation order left.

PS: You are right about scoping.  But it's not critical -- it we could
have certain rules, we coul write predictable and readable code.  Some
time ago, I used my own realization of "where" (via camlp4) and often
had to use brackets. Even then, I think that my code was quite readable.
Now, I think than haskell rules (whare as part of definition, not
expression) are quite rasonable.

> Dave Brown


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: