SwensenSoftware / unquote

Write F# unit test assertions as quoted expressions, get step-by-step failure messages for free
http://www.swensensoftware.com/unquote
Apache License 2.0
285 stars 26 forks source link

Support tail recursion #97

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
let tailTest =
  <@   let rec sum a b = if a > 0 then sum(a - 1) (b + 1) else b
       sum (1024*1024*128) 0 @>
tailTest.Eval()

should work without StackOverflowException

Original issue reported on code.google.com by lostfree...@gmail.com on 28 May 2012 at 2:08

GoogleCodeExporter commented 9 years ago

Original comment by stephen....@gmail.com on 29 May 2012 at 4:01

GoogleCodeExporter commented 9 years ago
Hi @lostfreeman,

Just want to let you know that I am definitely keen on fixing this issue. But 
after some investigation, I fear it is near-impossible to implement within the 
framework of Unquote's reflection-based compiler. I think the F# team would 
have to build support for tail recursion into their F# reflection API for this 
to work. Indeed, this might be consider a bug in FSharpValue.MakeFunction, 
which is what we use to make F# functions from Lambda expressions.

Original comment by stephen....@gmail.com on 14 Oct 2012 at 3:35

enricosada commented 7 years ago

I think the F# team would have to build support for tail recursion into their F# reflection API for this to work. Indeed, this might be consider a bug in FSharpValue.MakeFunction, which is what we use to make F# functions from Lambda expressions

@dsyme @eiriktsarpalis do you know is that's still an issue in quotation?

dsyme commented 7 years ago

@stephen-swensen

A couple of things - first, Unquote is amazing and I should have been helping with issues like this.

Second, substantively:

I think the F# team would have to build support for tail recursion into their F# reflection API for this to work. Indeed, this might be consider a bug in FSharpValue.MakeFunction, which is what we use to make F# functions from Lambda expressions

Yes, I can see what you mean. Could you add this issue to http://github.com/fsharp/fslang-suggestions and we can iterate towards a concrete design suggestion here?

thanks! don

p.s. please feel free to contact me directly if you want to discuss any technical issues

stephen-swensen commented 3 years ago

@dsyme three years later, thanks for kind words and sentiments :) I'll yet follow up with a support issue when I'm able to focus on this issue again.

Stephen