Re: [pure-lang-users] Runaway trains
Status: Beta
Brought to you by:
agraef
From: Eddie R. <er...@bm...> - 2008-08-20 13:18:52
|
On Wed, 2008-08-20 at 13:48 +0100, John Lunney wrote: > Hey guys, > I was playing round with the symbolic computation stuff from the > examples, and had the idea of trying to reduce -(a) to -a. > So I entered the following line: > -(a) = -a; On my box: > -(a); -a So the lhs is the same as the rhs already. So your making a rule like x = x; The interpreter is reducing -(a) to -a which is the same as -(a) and then reducing -a to -a and then reducing -a to -a and then ... Shazam! an infinite loop. > Pure instantly took almost 100% of my processor and went into what I > presume was an infinite loop. I had seen this coming, of course. > Another time I tried it, Pure just quit with no error. Memory usage > seems to remain constant. Yes, the first one is caused by an infinite loop. The second one sounds weird and something seems wrong with quiting. Memory usage should be constant because nothing is being allocated, the interpreter is just firing the same rule over and over. > Should runaway things like this be detected or not? I'm guessing not... The interpreter is just going to evaluate whatever rule you give it. If you code "while (1) ;" in C the resulting program is going sit there and loop until you kill it. HTH. I know Albert can do a better job with this. e.r. |