Re[Haskell-cafe] [2]: memoization

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Sep 10 08:50:54 EDT 2009


Hello staafmeister,

Thursday, September 10, 2009, 4:23:26 PM, you wrote:

> This doesn't work and is exactly what I'm afraid the compiler is going to
> do. Cache needs to
> be associated with the function f.

> Otherwise one would get conflicts

well, technique i used is well known, we would have something like C
global variable. initiating it inside function is a technique i never
seen, i *expect* that it would be the same since syntax scoping
doesn't change semantics, but it would be better to ask people that
know haskell better

if you want to disable sharing of cache you need to make function (or
some string representing it) an explicit parameter. i see that you try
to do it via declaring f at the outer function level and x in the
inner function, but this shouldn't work. the following:

outer f = inner
  where inner x = f x*f x

and

outer f x = f x*f x

are exactly the same. in general, consider Haskell as pure math
notation with all its features



-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list