3

One of the amazing things about Haskell is the Spineless Tagless Graph Machine (STG). At the time, (according to SPJ) it was written to enable the laziness that enabled functional programming to work on the limited hardware of the time. Subsequently it has been shown to have any additional benefits for functional programming.

When we see languages like Scheme - recursion features prominently (as it does in Haskell). Part of what makes this particularly effective is the feature known as Tail Call Elimination. The reason you want Tail Call Elimination is because if a function calls itself 1000's of times, it can blow the stack, even stackoverflow. [sic]

Now Haskell has some interesting options for Tail Call Elimination. What we see is that:

Haskell's recursive functions aren't evaluated in a very recursive way! The only stack of calls hanging around are the multiplications themselves. If (*) is viewed as a strict data constructor, this is what's known as guarded recursion (although it is usually referred to as such with non-strict data constructors, where what's left in its wake are the data constructors - when forced by further access).

My question is: Are the Haskell options for Tail Call Optimisation indicative of the Spineless Tagless Graph-machine?

Community
  • 1
  • 1
hawkeye
  • 34,745
  • 30
  • 150
  • 304
  • 1
    Not sure if relevant, but GHC moved from the push/enter evaluation model to the eval/apply one a few years ago because the latter started to become more performant. This changed the calling conventions significantly. I have no precise idea about whether TCO is used right now in GHC, though. – chi Jun 26 '16 at 08:04
  • 2
    Of course TCO is still used. – augustss Jun 26 '16 at 09:58
  • Thanks @chi - could expand on the implications of that change? – hawkeye Jun 26 '16 at 12:52
  • 1
    I can't really recommend anything but checking the [Making a fast curry](http://community.haskell.org/~simonmar/papers/evalapplyjfp06.pdf) paper, and possibly a few more... – chi Jun 26 '16 at 16:37
  • Cool - can you expand that into an answer? – hawkeye Jul 06 '16 at 12:29

0 Answers0