<mcguire>
Tail call elimination is a good question.
<TwoNotes>
It would not eliminate them, but turn them into a jump to the head of the function again. Many compilers can do this, but some, such as Erlang, actually require it. I thought I saw somewhere that Pony does this too, but now I can not find the reference
<SirWillem>
Thanks mcguire for the link, I didn't see it.
<TwoNotes>
The gernal term is "tail call optimization" or "tail recursion optimization"
<SirWillem>
That is what I meant
<SirWillem>
Good to get the semantics right.
<TwoNotes>
I cannot find mention of it in the tutorial
<SirWillem>
Neither could I.
<mcguire>
If we're going to be technical about it :-), full on tail call optimization jumps to the beginning of any function call in tail position.
<SirWillem>
I did hear it mentioned briefly in a video I watched.
<mcguire>
A quick-n-dirty test suggests that it is. I wonder how long it'll take to overflow an ISize.
<TwoNotes>
If the compiler did not optimize tail calls, eventually you would run out of memory for the stack
<SirWillem>
Ah yes I'll try some experiments myself.
<mcguire>
Longer than I care to wait. :-P
<mcguire>
actor Main
<mcguire>
new create(env: Env) =>
<mcguire>
foo(env, 0)
<mcguire>
fun foo(env: Env, i: ISize) =>
<mcguire>
end
<mcguire>
env.out.print(i.string())
<mcguire>
if (i % 1000) == 0 then
<mcguire>
foo(env, i+1)
<mcguire>
Mutual recursion looks good, too.
<mcguire>
Note: this is with optimization.
<mcguire>
Yep, compiling with -d produced an executable that seg faults quickly.
<SirWillem>
Cool!
<SirWillem>
does that quoted code need an imports? I tried it and it didn't print.
<TwoNotes>
So tail optimization is an 'optimization' that can be turned off. It is not a part of the language specification. So Pony differs from Erlang in this respect
<mcguire>
? ThatI just sent? It should, if compiled by ponyc (with no -d)
<TwoNotes>
Since Erlang does not have loops of any kind, you use tail recursion to get the same ffect, so it is more important
aturley has joined #ponylang
<SirWillem>
That makes sense.
<SirWillem>
But I don't see the point in turning off this optimization.
aturley has quit [Ping timeout: 260 seconds]
jemc has joined #ponylang
<sylvanc>
good experimenting! and yes, pony does tail call optimisation with optimised binaries :)
<sylvanc>
the reason not to have it, SirWillem, is to make it easier to debug some problems
<SirWillem>
Awesome! Can't wait to get there in the source.
<sylvanc>
which is why it's only turned off with -d (ie --debug) in pony
<SirWillem>
Ah good reason.
<SirWillem>
Ah that makes sense.
<SirWillem>
How long does compilation take for a large project?
jemc has quit [Ping timeout: 260 seconds]
<SirWillem>
Also is Inling possible?
tm-exa has joined #ponylang
<TwoNotes>
My 2400 line, 6 executable, project takes 25 seconds to build, on an x86_64 machine
<TwoNotes>
Building on a RasberryPi3 takes about 2.5 times longer
<TwoNotes>
But remember than all the packages you include also get reocmpiled, so my total is probably 3-4,000 lines
<TwoNotes>
SirWillem, one thing you lose with tail recursion optimization is any evidence in the backtrace that it has even happened. This can make debugging difficult
tm-exa has quit [Quit: Computer has gone to sleep]
SirWillem has quit [Ping timeout: 240 seconds]
tm-exa has joined #ponylang
TwoNotes has quit [Quit: Leaving.]
tm-exa has quit [Quit: Computer has gone to sleep]
aturley has joined #ponylang
aturley has quit [Ping timeout: 240 seconds]
SirWillem has joined #ponylang
<mcguire>
Inlining is indeed possible and really nice. One of the things sylvanc pointed out about Array.find(...predicate...) is that the lambda expression that you pass to find (or the default if you don't pass anything) is inlined and completely disappears, performance wise.
jemc has joined #ponylang
graaff has quit [Quit: Leaving]
tm-exa has joined #ponylang
aturley has joined #ponylang
<SirWillem>
Great to know!
SirWillem has quit [Remote host closed the connection]
aturley has quit [Ping timeout: 252 seconds]
jemc has quit [Ping timeout: 252 seconds]
tm-exa has quit [Quit: Computer has gone to sleep]
SirWillem has joined #ponylang
SirWillem has quit [Remote host closed the connection]
aturley has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
Matthias247 has joined #ponylang
SilverKey has joined #ponylang
jemc has joined #ponylang
trapped has quit [Read error: Connection reset by peer]
Matthias247 has quit [Read error: Connection reset by peer]
SilverKey has quit [Quit: Cheerio!]
aturley has joined #ponylang
nyarum has quit [Read error: Connection reset by peer]