Version française
Home     About     Download     Resources     Contact us    
Browse thread
Estimating the size of the ocaml community
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Estimating the size of the ocaml community
On Sat, 2005-02-05 at 03:00, Oliver Bandel wrote:

>     Explanation: Pattern matches are like nested if's now in OCaml. The Pattern
>     that matches first in the code, will be executed!!!
>     This is NOT functional, this is imperative behaviour!

No. If chains are perfectly functional .. in fact control
transfer is little more than lazy evaluation.

What you are *actually* complaining about is loss of transparency.
When you write

	if A then .. else if B then ..

the *actual* guard on the  second case isn't B, but

	B and not A

therefore the order of writing matters. So you cannot
transparently reorder the branches.

What you're *actually* asking for is probably a match construction
that guarrantees the branches are mutually exclusive so that
the order of writing is irrelevant.

In particular, there is a related construction that
executes *all* matching cases, and the mutually exclusive
branches match is a special case of that which only
takes one branch. In particular, a parallel match,
which executes all the branches, possibly concurrently,
would work well when the branches are exclusive..
(since no concurrency is required .. :)

In fact, Ocaml 'match' syntax is chosen to do 20 quite
distinct operations with one syntax: i.e. it is just
a convenience. The compiler tries to unravel it
to produce better code -- but the programmer
does not actually know how well it will perform
without heavy analysis.

More discrete constructions would give the programmer
much more idea of the actual semantics and implementation,
BUT it would then be much harder -- less transparent --
to modify the code.


-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net