Hi,

This is a problem not specific to F#: the try with block prevents the tail recursion optimization.

let foo x = try bar x with _ -> 0

Here the calling bar is not a tail call. If the call raises an exception, we'll have to execute the "with" block, that is we'll need to go back to the foo function (thus, we need to keep the stack trace). The same happens when the call is a recursion (as in your example).

The solution is probably to move the "try with" outside the function.

let foo list =
let rec aux list =
let list' = processList list
aux list'

try aux list
with ecc -> showCrashWindow ecc

By on 12/17/2009 4:57 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper