From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id GAA21344; Sat, 14 Jul 2001 06:04:45 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id GAA21305 for ; Sat, 14 Jul 2001 06:04:44 +0200 (MET DST) Received: from verdot.inria.fr (verdot.inria.fr [128.93.11.7]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f6E44Hf09274; Sat, 14 Jul 2001 06:04:17 +0200 (MET DST) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id GAA25779; Sat, 14 Jul 2001 06:04:17 +0200 Date: Sat, 14 Jul 2001 06:04:17 +0200 From: Daniel de Rauglaudre To: "Alexander V. Voinov" Cc: "caml-list@inria.fr" Subject: Re: [Caml-list] Generation of streams is slow Message-ID: <20010714060417.A25766@verdot.inria.fr> References: <3B4F70D7.82E58A91@quasar.ipa.nw.ru> <20010714042701.A24266@verdot.inria.fr> <3B4FB39D.10D1F6D5@quasar.ipa.nw.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0us In-Reply-To: <3B4FB39D.10D1F6D5@quasar.ipa.nw.ru>; from avv@quasar.ipa.nw.ru on Fri, Jul 13, 2001 at 07:51:09PM -0700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Fri, Jul 13, 2001 at 07:51:09PM -0700, Alexander V. Voinov wrote: > Yes, the difference is substantial, but it gets longer and longer anyway > with more elements parsed (for a slightly more complex program, which > parses the stream as it is generated) and crashes at some point. I did not test, but looking at your code, I see that neither parse_stream nor parse_stream' is tail recursive! It is not a question of parsers, now: your recurive calls are never the last action. Perhaps this version would work (not tested): let rec parse_stream list s = match s with parser [< 'i; s' >] -> begin if i mod 1000 = 0 then begin printf "picked element %d\n" i; flush stdout end; parse_stream (i :: list) s' end | [< >] -> (printf "end\n"; flush stdout; List.rev list) let _ = print_list (parse_stream' [] (gen_stream 700000)) -- Daniel de RAUGLAUDRE daniel.de_rauglaudre@inria.fr http://cristal.inria.fr/~ddr/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr