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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Joerg Czeranski <jc@j...>
Subject: Re: [Caml-list] Evaluation Order
David McClain wrote:
> My mistake was writing
>
> let ans = process_stream() + process_tail()
>
> [...]
>
> The results of these two operations, integers, are arithmetically commutable
> under addition. But what isn't commutable is the order in which these
> operations occur. No current type checking in OCaml (or any other language
> with which I am familiar) could help catch this mistake.

A minor nit: commutativity isn't involved.
The problem would be the same for

  let y = f() / g()

and even

  let y = h (f()) (g())

Operators (and functions) just don't care in which order their operands
(parameters) are evaluated.

I really like Haskell's solution, but I've never used Haskell much.
The main reasons for this is OCaml's superior Unix binding
and it being much easier to build and install.

jörg
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr