[go-nuts] What happens when you call another method within a method set at the end of a method

2019-04-06 Thread Louki Sumirniy
I have become quite interested in tail-call optimisation and more distantly in code that assembles trees of closures all tied to the same scope through parameters to reduce stack management for complex but not always predictable input. As I have learned from some reading, tail call optimisation

Re: [go-nuts] What happens when you call another method within a method set at the end of a method

2019-04-06 Thread Jan Mercl
On Sat, Apr 6, 2019 at 9:34 AM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: A tail call is in the first approximation just what it says: call foo ret Nothing other is really that much special about it. -- You received this message because you are subscribed to the

Re: [go-nuts] What happens when you call another method within a method set at the end of a method

2019-04-06 Thread Robert Engels
But yes, similar to how all recursive functions can be rewritten using loops, which are more efficient, that is essentially what tail call optimization does - just that the process it automatic. > On Apr 6, 2019, at 5:21 AM, Jan Mercl <0xj...@gmail.com> wrote: > > On Sat, Apr 6, 2019 at 9:34 A

Re: [go-nuts] What happens when you call another method within a method set at the end of a method

2019-04-06 Thread Ian Denhardt
Quoting Robert Engels (2019-04-06 08:00:02) >But yes, similar to how all recursive functions can be rewritten using >loops, which are more efficient, that is essentially what tail call >optimization does - just that the process it automatic. Not all recursive functions -- just tail ca

Re: [go-nuts] What happens when you call another method within a method set at the end of a method

2019-04-06 Thread Michael Jones
The opportunity to optimize yb tail-call elimination comes up in my coding from time to time. It is generally trivial to do but sometimes less so, and this example by Ian Denhardt is one I'd never considered and one that would make doing the rewrite yourself impossible. Generally though it is ver

Re: [go-nuts] What happens when you call another method within a method set at the end of a method

2019-04-06 Thread Robert Engels
You are correct, but I think an explicit stack is faster than most function calls, but it depends on number of parameters needed, etc. but maybe not...:) > On Apr 6, 2019, at 12:20 PM, Ian Denhardt wrote: > > Quoting Robert Engels (2019-04-06 08:00:02) > >> But yes, similar to how all recur