[clean-list] Re: (digest): Clean and scientific programming
Siegfried Gonzi
siegfried.gonzi@kfunigraz.ac.at
Mon, 03 Sep 2001 12:28:24 +0200
From: Sven-Bodo Scholz <sbs@informatik.uni-kiel.de>
> The programmer has to think about the allocation and potential
> reuse of his array; he has to organize the allocation and deallocation of memory
> portions turning a functional data structure into a state-full one.
Yesterday one strange behavior bothered me. The following code snippet:
gh:: !Int {*{#Real)) -> {*{#Real}}
gh a marray = kl a marray
where
nj = (size marray)
kl:: !Int {*{#Real}} -> {*{#Real}}
| n == nj = marray
= kl (n+1) { marray & [n] = ....}
This program will deliver the error message that "kl" doesn't get a
unique array at the expected position.
But if I use:
gh:: !Int {*{#Real)) -> {*{#Real}}
gh a marray = kl a marray
where
// nj = (size marray)
kl:: !Int {*{#Real}} -> {*{#Real}}
| n == (size marray) = marray
= kl (n+1) { marray & [n] = ....}
It works. It seems the compiler cannot beforehand decide when it has to
calculate nj and therefore has not appropiate unique informations at its
disposal.
S. Gonzi