From: Paul Lutus Date: 2006-11-25T04:47:47+09:00 Subject: Re: [OT] Bug in ruby? Charles D Hixson wrote: / ... > I'll grant that good error messages are a hard problem, but I frequently > find them totally exasperating. E.g., if a loop isn't properly closed, > the error message should point to where it started rather than several > lines after the end of the program. But the interpreter cannot do that without reading the programmer's mind. Maybe the programmer intended to complete the loop in some code, not yet written, that extends beyond the present end of the program. The evidence is that the interpreter's scanner ended up at the end of the file, still happy with the syntax up to that point. > (Well, perhaps this one's been > fixed. I don't remember encountering it recently. But if it hasn't > been, I consider it a bug in Ruby.) It is not a bug in Ruby if the incomplete loop could in principle continue beyond EOF. > In this case the bug was in the message not stating which variable had a > nil value. You may not think of it as serious, but he reports spending > several hours on it, and I'd call that a bug. It is not a bug, at least, not in Ruby. At the point at which the error condition arises, the '+' method doesn't know the names of the variables that produced its inputs, it only knows that one of them is nil. Remember that this is a runtime error. And the OP used a debugger but still didn't realize there was a possibility he hadn't considered. This is not something any finite-sized language can possibly deal with. Also remember: in an interpreted language, every increase in hand-holding runtime comprehensiveness decreases execution speed. > Remember, Ruby is being recommended to total neophytes as a good > language to start with. That means that good diagnostic error messages > are essential! It also means that, as in all computer programming for all time, neophytes have to pay attention to details. The single most difficult part of learning how to program is to fully grasp how simple-minded computers actually are. Successful programmers know exactly how a computer will react to their code. Learning this, reducing it to a matter of instinct, takes time. -- Paul Lutus http://www.arachnoid.com