Algorithmic lists

Ulf Wiger etxuwig@REDACTED
Tue Oct 17 08:58:06 CEST 2000


On Mon, 16 Oct 2000, Andy with Recycled Electrons wrote:

>Tell me if I'm wrong, but lazxy evaluation would screw up Real Time,
>right?
>
>Andy
>Recycled Electrons

Well, not any more than would the otherwise mandatory rewrite into an
ets:first()/ets:next() loop. The real-time behaviour will be the
same, but the amount of changes needed to the code will be less with a
lazy list syntax.

In a system like the AXD 301, it is taken for granted that programmers
must know what they are doing at all times (or at least most of the
time). Another example of something that can screw up real time
behaviuor is distributed message passing; it's a vital part of our
system, but its use must be tightly controlled.

Obviously, with lazy lists, it's quite easy to create an infinite
loop, but not much more so than with the first program Erlang we
teach:

factorial(N) ->
   N * factorial(N-1);
factorial(0) ->
   1.

(yes, I know this function can loop endlessly.)

/Uffe


>> > We (a few lunatics at AXD 301) would like to see the lists module
>> > support an alternative formulation of lists.
>> 
>> They are indeed elegant, and Joe was correct - they're called lazy lists,
>> and should be implemented using zero-argument funs. To give a type
>> declaration of sorts:
>> 
>> 	LazyList :: [] | [term() | fun() -> LazyList]
>> 
>> Writing a module 'lazy_lists' should be a doddle. In fact, I might do it
>> myself.
>> 
>> 	/Richard Carlsson
>> 
>> 
>> Richard Carlsson (richardc@REDACTED)   (This space intentionally left blank.)
>> E-mail: Richard.Carlsson@REDACTED	WWW: http://www.csd.uu.se/~richardc/
>> 
>> 
>
>Sincerely, 
>
>Andy Allen
>Recycled Electrons
>email: andy@REDACTED
>
>
>

-- 
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