Browse thread
Help me find this pdf
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] Help me find this pdf |
> On 18/10/2007, skaller <skaller@users.sourceforge.net> wrote: > > No, but Felix does it by default > > What do you mean? You mean that if I write a map > > map f [] = [] > map f x:xs = f x : map f xs > > I can apply it both to infinite and lazy lists? No, it means that when you write fun map[t] (f:t->u) (xs:list[t]) => ... it is indeterminate whether f and/or xs are evaluated before calling map (eager evaluation), or whether they're replaced by their arguments in the definition of map (lazy evaluation). If the list itself is given by a formula, this means the formula for the list may replace 'xs' in the map, and only be evaluated when required. In particular the list may be enumerated eagerly or lazily so it must be a list, not a stream, or your program may fail to terminate. In Felix a list is given by union list[t] = Empty | Cons of t * list[t]; and the combinators for | and * are eager, so all inductive data types in Felix are eager. Only function application has indeterminate timing. I'm not sure I can fix this because, for example, a product is just a C++ struct, and C++ operator. cannot be overloaded. However operator->() and operator *() can be overloaded, so it just might be possible to make pattern matching lazy. Thanks for asking this question .. forced me to think! -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net