From: David King Landrith Date: 2004-04-03T04:43:58+09:00 Subject: Re: Variable names On Apr 2, 2004, at 11:30 AM, Dave Thomas wrote: > > On Apr 2, 2004, at 10:20, David King Landrith wrote: >> Is there any way to access the name of a given variable instance from >> within it? In other words, for any object x, is there C function to >> which I can pass self to determine that the program calls it 'x'? > > You have the file name and line number, and you may even have the file > itself in SCRIPT_LINES, so you could cheat and find the name from > that. I'm looking for something more general. We don't actually have such a print_line method, I simply made it up for the email since it was a good example. > I'm interested in tis experiment: how often does it catch a problem > that you didn't catch though unit testing? Putting that another way: > how often do you see these type errors in testing, and how often in > production? Often enough to justify it, given the complexity of our application. We've written a Ruby api upon which our program is based, and it has about than 18,000 lines (25k ruby, 3k in C). Our program (or group of programs surrounding the application) totals least 25,000 lines. As a consequence, we have tons of unforeseen contingencies and type checking provides an important way to eliminate one class of these. Since most of our application touches a SQL database in some way (we've rolled our own ruby database API in C to handle persistence layers and eliminate the overhead endemic to the dbd/dbi arrangement, since our tables have 10s of millions of records and we're pushing and pulling gigabytes of data) destructive errors are a real possibility; E.g., we don't want to insert # into a varchar field. And since we often have a method calling a method calling a method and so on, without type checking it can be quite difficult to locate where our string got swapped for something else. Also, given the complexity of the program, the behavior that elicits the swap may very well be latent in very, very well tested code. Does this make sense? ------------------------------------------------------- David King Landrith (w) 617.227.4469x213 (h) 617.696.7133 Life is tough. It's even tougher if you're an idiot. --John Wayne ------------------------------------------------------- public key available upon request