Browse thread
[Caml-list] beginner question about tail recursion
[
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@o...> |
| Subject: | Re: [Caml-list] beginner question about tail recursion |
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