[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: functional languages ill-suited for large programs?
Cc: ll1-discuss@ai.mit.edu
From: Jim Blandy <jimb@redhat.com>
Date: 01 Nov 2003 00:03:40 -0500
Alan Bawden <Alan@LCS.MIT.EDU> writes:
...
> fib = ((map fib' [0 ..]) !!)
> where
> fib' 0 = 0
> fib' 1 = 1
> fib' n = fib (n - 1) + fib (n - 2)
>
> is a memoized version that executes quite quickly. It seems to me that I
> have just expressed the notion of a memoized function in a purely
> functional language.
Yes, you have. Please check my memory of Haskell: this computes
(lazily) an infinite list whose n'th element is fib' n, and then
curries the subscripting operator !! --- is that right?
Yup.
But what if I needed to be able to forget old memoized values?
Then you'd be moving the goal posts! What you -said- was that a functional
language prevented you from expressing memoization. Now you've changed
your tune!
If you've got an argument that concealed state *isn't* often useful,
then that'd be a direct rebuttal.
Well, I wasn't trying to rebut your overall argument nor was I trying to
claim that concealed state isn't useful. I was just pointing out that your
-specific- claim (that functional languages prevent you from expressing
memoization) isn't true.
I was also indirectly making the point that it can be surprising what -can-
be expressed in a functional language. I think you're right that state is
indispensable in many situations. But I'm not as certain as I used to be
about exactly what those situations are, I've been surprised too often...