English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Evaluation order of Stream.from
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-05-22 (15:48)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] Evaluation order of Stream.from
YAMAGATA yoriyuki wrote:

>Hi, folks.
>I have a question about Stream.from.  If I create a stream by
>Stream.from f by some function f, in what order f is called?  I mean,
>is it guaranteed that f is always called as f 1, f 2, f 3, ....? or is
>the order like f 1, f 3, f 5, f 7, f 2, f 4, .... possible?
>The manual states nothing, so maybe I have to assume there is no
>guarantee.  But then using a function with side effects
>is nearly impossible, which is unfortunate.
>I tried to understand the source, but it is full of magic and anyways,
>the source does not make any guarantee for the future.

The same issue arises for List.rev_map. By experiment, I find it applies
its function argument from the head of the list argument, in order,
which is suggested by  the statement that it is tail recursive.
But it isn't *guarranteed* by the manual, and it probably should be.

To be pedantic .. the 'tail recursive' bit is non-information.
Only source code has that property. List.rev_map is a standard library
routine. It should be characterized by saying it has
linear performance, with constant storage overhead.

John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners