Sometimes I get pattern problems that results in my functions recursing indefinitely. TCO mens I don't run out of stack.Is there a trick to working out just what is looping?
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
One of the nice things about Ruby is that if a process goes haywire, it isn't too hard to get a stacktrace. (Of course, that's largely because it doesn't have TCO).
One of the things that I've always found problematic about Erlang is that the reporting assumes that every app is a massive app, and so doesn't make the simple case simple.
Would it be possible to wrap Elixir execution somehow, so that if it gets a ^C it goes into something a little more user friendly and meaningful than
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
And, if it is possible, could someone give me some pointers? I'm a firm believer in "he who complains, fixes".
Dave
Thank you for writing all this up Alexei!
Alexei:
Thanks for summarizing this. It's pretty close to what I had to go through (although I found my process by PID) to find that it was looping in reduce.
And, don't get me wrong. This isn't an Elixir issue. The problem is that Erlang is written for really large scales, and therefore has to give you everything when you ask for information. For complex system, this is just what you need. But for the simple case, the steps that both you and I went through were pretty indirect.
In Ruby, I'd just add trap("INT") { raise } at the start of my code.
Here's an example
def fred
bert
end
def bert
wilma
end
def wilma
loop { sleep 0.01 }
end
trap("INT") { raise }
fred
When run:
dave[~/tmp] ruby loop.rb
^Cloop.rb:10:in `sleep': Interrupt
from loop.rb:10:in `block in wilma'
from loop.rb:10:in `loop'
from loop.rb:10:in `wilma'
from loop.rb:6:in `bert'
from loop.rb:2:in `fred'
from loop.rb:13:in `<main>'
To do it on a running process, I get into it with gdb, then just rb_eval("raise")
I may take a stab at seeing what I can do in this area once I dig out from the backlog caused by the book ;)
Dave
Just an idea> iex :observer.start()