caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Jeffrey Loren Shaw <shawjef3@msu.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] lazy evaluation of combinator parsers
Date: Sat, 24 Mar 2007 17:48:03 +1100	[thread overview]
Message-ID: <1174718883.7517.46.camel@rosella.wigram> (raw)
In-Reply-To: <E1HUv3J-0002P1-Bt@sys29.mail.msu.edu>

On Fri, 2007-03-23 at 21:28 -0400, Jeffrey Loren Shaw wrote:

> let alt p1 p2 xs = append (p1 xs) (p2 xs) 
> 
> (* regex ? *)
> let opt a = alt a epsilon 
> 
> let rec recseq a =
>  seq
>    a
>    (recseq a) 
> 
> (* regex * *)
> let rec star a =
>  recseq (opt a) 
> 
> However, "star (symbol 'a')" causes a stack overflow. I'm not sure why, 
> since my seq and alt functions are lazy. 

Arguments are evaluated right to left eagerly, so

let rec recseq a = seq a (recseq a) 

is instantly an infinite loop. seq is not called here,
it's second argument diverges.



-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


      reply	other threads:[~2007-03-24  6:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-24  1:28 Jeffrey Loren Shaw
2007-03-24  6:48 ` skaller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1174718883.7517.46.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=shawjef3@msu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).