[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: functional languages ill-suited for large programs?

Tom Lord wrote:
> Has anyone ever tried to make a purely functional, lazy language
> implementation in which _every_ function is implicitly cached?  The
> compiler optimization shifts in that case from "when should F be
> cached" to "when is clearly not worth bothering caching F" which is an
> easier (but still open-ended) problem.

The approach Bento follows is somewhat close: evaluate lazily,
cache aggressively, and let the compiler/interpreter, for the most
part, decide precisely *when* to cache.  What the programmer decides
is *where* to cache.  By default, functions are cached internally by
lexical scope, so that, for example, a function that appears in
identical form twice in an expression is evaluated only once.  But the
programmer can override this and specify a different lexical scope to
govern the caching behavior, as well as the repository to use.  By
promoting the caching behavior of a function to a higher lexical scope,
you get a kind of state without mutation.  Promoting it all the way up
to global scope and specifying an external database as the repository 
gets you global persistence -- without ever having to call a save

Michael St. Hippolyte