From: Jamis Buck Date: 2004-08-23T23:40:48+09:00 Subject: Re: How to check syntax Andreas Schwarz wrote: > Graham Nicholls wrote: > >> OK, so its not a syntax error. Pedants :-) There ought to be a utility to >> look for variable references, etc. > > > This is almost impossible in dynamic languages like ruby. Variables can > be defined everywhere, in eval(), conditional code, etc. You don't find > out until you execute it. > > > Now, I realize that this may be hard as > >> its presumably akin to part of writing a compile. What I'd like to know, >> then is how to avoid the above - its a real nuisance in "scripting >> languages" (Oh and if you don't like that term, get over it - you know >> what >> I mean, python, perl(ugh!) Ruby & the like) > > > Use unit tests. Just what I was going to suggest. I'm (re)writing Copland right now, refactoring to make unit testing easier, and unit testing has been a GODSEND. I've found bugs doing unit testing that I wouldn't have found otherwise until much, much later, bugs much like what the OP was asking about. Admittedly, if you've never done unit testing before, it is something of a learning curve to (1) figure out the API (though it is wonderfully clean and straightforward compared to JUnit), and (2) learn how to write code that can be unit tested. However, TAKE THE TIME TO LEARN HOW TO DO IT! It will repay you many (many!) times over in time saved debugging difficult problems. -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis "I use octal until I get to 8, and then I switch to decimal."