Algorithmic lists

Richard Carlsson <>
Tue Oct 17 11:53:50 CEST 2000


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

> Let me clarify...
> 
> Accessing a list is a simple, real-time operation.  
> 
> Accessing a Lazy List may mean accessing a megapixel image from Hong Kong,
> where it is ray traced in true color based on several dozen light
> sources.
> 
> In other words, there would be no gurantee of ANY timing constraints.  As
> long as the "real time" system realizes this, everyone is happy. 

Programming with lazy evaluation as the general rule (as in Haskell) does
indeed make it difficult for the programmer (unless he happens to be John
Hughes) to get an intuitive grasp of how time-consuming a particular
computation will be. It does not have to involve disk or network access to
be so: one can fairly easily happen to create a function that seems
straightforward but actually has exponential space complexity, and if you
are not one of the cognoscenti, the ways of rewriting it so it behaves
nicer may simply appear like waving so many dead chickens.

That said, one can do a lot of neat things with lazy evaluation (even if
you simulate it in a strict language like Erlang), and a library for
working with lazy lists could be a nice thing to have, since it seems more
likely that someone who uses that library does more or less know what he
is doing, and why.


> Also, is there a way to overload operators (not function calls) in
> Erlang? I'd love to overload "+" or "-" for a specific kind of input,
> so that a call is made to my function.  The data units I am passing in
> are 3-element tuples right now, but I can change that.

No, there isn't. (Or rather, yes, there is, it's called "parse
transforms", and you should really not be doing it.) My advice: implement
a nice abstract datatype with functions "add(X, Y)", "subtract(X, Y)",
etc., or if you really feel you want `+' and `-', you can actually call
your functions "'+'(X, Y)" and "'-'(X, Y)" as long as you use
single-quoting.

	/Richard Carlsson


Richard Carlsson ()   (This space intentionally left blank.)
E-mail: 	WWW: http://www.csd.uu.se/~richardc/




More information about the erlang-questions mailing list