Lazy lists - an implementation.

Ulf Wiger <>
Wed Oct 18 14:39:40 CEST 2000

On Wed, 18 Oct 2000, Richard Carlsson wrote:

>Yes. But I think that the sort of "damage control" that Ulf wanted
>will in the end make the code deteriorate into something unreadable,
>bug-prone and unpredictable. Better rewrite the code once and for
>all into something that can be read and understood, if you decide
>that you want to use this sort of technique.

I wrote the following in a previous post.

"Of course, these rewrites are usually warranted for other reasons,
but timing is always an issue in production projects. If we can, we'd
like to schedule complete rewrites to some other time than during the
system test phase -- which is a fairly common place to find these


In practically all the circumstances where we've come across the poor
memory management behaviour that would make the code a candidate for
this type of reprogramming, we've also recommended quite assertively
that the code be rewritten, usually for a variety of other reasons as
well. Always, we get the same response: "sure we'd like to rewrite the
code, but there simply isn't time." 

This is the reality of complex product development projects in a
fiercely competitive environment: you can very seldomly afford a major
rewrite of code, so techniques for partial rewrites become very

We *have* performed major rewrites on a number of occasions - even
performed a total overhaul of a major part of the system. In all
cases where we've done this, it's been a success, but it is also a
huge undertaking - even in Erlang.

>No, as I said, I do absolutely not want to augment code handling normal
>lists with extra cases for continuations. That way lies madness!

We must be thinking of totally different problems. For the problems
I'm trying to solve, augmenting the list metaphor seems like the
logical way to go - certainly not madness.

Anyway, after talking to Björn G. on the phone, I'm prepared to drop
my suggestion in exchange for the following:

- functions like map, foldl, etc. on ets and mnesia tables
- list comprehensions on ets tables

This would bring us closer to our goal of making partial rewrites
much easier, while avoiding the philosophical woes that seem to
surface as soon as lazy evaluation is mentioned.

Ulf Wiger                                    tfn: +46  8 719 81 95
Strategic Product & System Management        mob: +46 70 519 81 95
Ericsson Telecom AB,              Datacom Networks and IP Services
Varuvägen 9, Älvsjö,                    S-126 25 Stockholm, Sweden

More information about the erlang-questions mailing list