Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@ozemail.com.au>
To: Matt Gushee <matt@gushee.net>
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] beginner question about tail recursion
Date: 31 Aug 2003 20:31:50 +1000	[thread overview]
Message-ID: <1062325909.15303.8.camel@localhost.localdomain> (raw)
In-Reply-To: <20030831063334.GA3405@swordfish>

On Sun, 2003-08-31 at 16:33, Matt Gushee wrote:

> 2. The recursive call can't be within a 'try' block.

I think that is not quite the correct rule, the rule should
be that the call can't cross a try block boundary.
For example:

let g x = 
	let y = 
		try h x with _ -> []
	in g y

This example _contains_ a try block.

let f x = 
	try
		let g x = h x
		in g x
	with _ -> ...

this example is _contained in_ a try block.

Both have tail calls to g. But in this example:

1  let rec readlines chnl =
2    try
3      let line = input_line chnl in
4      line :: (readlines chnl)
5    with End_of_file -> []

the call of readlines _crosses_ a try
block boundary.


-------------------
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


  parent reply	other threads:[~2003-08-31 10:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-30 22:52 Ram Bhamidipaty
2003-08-31  6:33 ` Matt Gushee
2003-08-31  9:12   ` Remi Vanicat
2003-08-31 15:53     ` Matt Gushee
2003-08-31 10:31   ` skaller [this message]
2003-08-31 10:06 ` [Caml-list] beginner question about tail recursion (caml: addressed to trusted sender for this address) Warren Harris

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=1062325909.15303.8.camel@localhost.localdomain \
    --to=skaller@ozemail.com.au \
    --cc=caml-list@pauillac.inria.fr \
    --cc=matt@gushee.net \
    /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