From: Bill Atkins Date: 2004-10-06T23:23:12+09:00 Subject: Re: quality of error messages On Wed, 6 Oct 2004 22:48:49 +0900, Joachim Wuttke wrote: > Hi Ruby developers, > > after spending some time with Perl and Python, I am > currently exploring Ruby. While I am quite enthusiastic > about some of its features, I am increasingly preocuppied > about the difficulties to localize errors. > > Example 1: missing "end" in > -> I forget to close a "class" or a "do" or a "if" block - > but which one ? Shouldn't the system be able to name > possible locations of unclosed block openings ? From what I understand, it's pretty difficult for Ruby (or any other compiler) to figure out where the improperly-ended block began. Using ruby-mode or some other automatic indenting system can help you spot these errors. Consider the following C code: int main() { if(1) { // do something int var = 34; while(var < 10) { var--; } } gcc gives a similar message ("syntax error at end of input"). Obviously, the bracket for the if statement was never closed, but it's difficult for a compiler to tell where it was supposed to end. (For example, is the bracket closing the while meant to close the if statement?) > Example 2: NoMethodError: undefined method. > -> Wrong, I defined the method. I just forgot to > include it in the attr_reader list. The system > shouldn't mislead me. Hmm, you shouldn't be listing methods you've defined in an attr list. the attr_* methods define getter and/or setter methods for the names you pass to them. Maybe you mean that you haven't declared an attr for some instance variable and running object.variable gives you a NoMethodError. In that case, remember that Ruby has no way to know the object.variable is an attr_reader as opposed to a regular, user-defined method. Just keep in mind that all accessors are just methods and then the error message will probably seem more informative. > > Developers, do you share my opinion that this would > be worth working upon ? I would really like to hear that > error messages will improve in future versions of the > interpreter. > > Once I open a Ruby/Tk session, error messages are > redirected to an annoying popup window. Can I disable > this behavior ? I would prefer to see errors in stdout, > even when I am running a GUI. > > Regards, Joachim > >