From: David King Landrith Date: 2004-04-03T07:31:43+09:00 Subject: Re: Variable names Now that's helpful. Thx. On Apr 2, 2004, at 5:18 PM, Dave Thomas wrote: > > On Apr 2, 2004, at 16:01, David King Landrith wrote: > >> Replies like this make this list next to useless. > > I'm sorry you felt like that: that certainly wasn't my intent. I was > simply trying to point out what others have said: the receiver of a > message is an object, not a variable, and it isn't always possible to > determine an appropriate variable name to use from within a receiver. > > Have you considered changing your approach slightly? Rather than > making it assertion-based, you could implement it more like cast-style > checking: > > def delete_file(str) > name = cast(:str, String) > # ... > > The 'cast' method could then verify its its first parameter was a > kind_of second parameter, and would have the name lying around if it > needed to report an error. > > The interpreter takes this kind of approach when ensuring that > parameters have the right behavior. In fact, it goes one better, > supplying the name of a conversion method to use if the object isn't > of the required type: > > name = cast(:str, String, :to_str) > > You could also do this, making the third parameter optional. > > However, I still question whether this is all worthwhile... :) > > > Cheers > > Dave > > > ------------------------------------------------------- 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