From: Charles D Hixson Date: 2006-11-22T15:07:29+09:00 Subject: Re: [OT] Bug in ruby? Bill Kelly wrote: > From: "Charles D Hixson" >> >> 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. (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.) > > Have you thought through how this might work? It seems the obvious > solution may not generate useful information. See for ex: > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/209336 > > > > Regards, > > Bill I admitted it was a hard problem ... but, well,... if functions are defined, and begins/ends balance within them, it probably happened before or after that. Not guaranteed, as there might be internal functions, but probable. If it's an end that is missing (usual case) start parsing from inner constructs out. Etc. (FWIW, I normally comment my ends thusly: end # initialize for just this reason. With Ruby syntax it is a REALLY hard problem. When this has occurred a few times I start really agreeing with the languages that do things like "end if" or "end def".) OTOH, it's also true that by compiling every time I enter a new definition I can generally handle this error with minimal problems .... but it would be a lot easier to include sufficient context markers to ensure localization of errors.