From: Charles Hixson Date: 2004-10-07T04:30:38+09:00 Subject: Re: quality of error messages Gavin Sinclair wrote: >On Thursday, October 7, 2004, 12:49:33 AM, Joachim wrote: > > > >>Encouraged by your quick response, I try to explain better >>what I meant in example 2: >> >> > > > >>class Foo >> attr_reader ... # here I forgot :pos >> def initialize >> ... >> @pos = ... >> end >>end >>... >>blabla = someClass.someMethod.link_to_another_class.methods_pos.oof >> >> > >=>> system complains "no such method" > > > >>Formally, the system is right: I forgot to declare the read >>access method for the variable pos. >> >> > >It tells you what method is missing from what object/class. This >should be enough for you to work out the problem. > > > >>But: >>(1) the system should tell me which method in the above >>chain causes the problem >> >> > >See above. Is your error message different from mine? (See IRB >transcript below.) > > > >>(2) as a naive programmer, with a background in other languages, >>I do not think of pos as method. I think of it as variable. >> >> > >The system is helping you, then, by reminding you it's a method :) >There's no such thing as direct access to instance variables in Ruby. > > > >>Once the system does not find a method, it could check whether >>there is a local variable of same name, and then print out >>an error message like >> "no method 'pos', no read access to local variable 'pos'". >> >> > >Too much effort. Better to just learn Ruby properly. I'm not >suggesting Ruby couldn't be made more user-friendly, but there's no >need in this area, IMO. > >Cheers, >Gavin > >... > > Perhaps not in that precise area, however when a block isn't close the error message should indicate the starting line of the unclosed block, instead of just mentioning a line one past the last line of the file. I have grown quite paranoid about creating large chunks of code between tests... And large here can mean only fixing more than five errors in one pass.