From: Todd Benson Date: 2007-11-16T18:31:17+09:00 Subject: Re: ruby wish-list On Nov 16, 2007 3:04 AM, Todd Benson wrote: > > On Nov 15, 2007 10:29 PM, Suraj Kurapati wrote: > > James Britt wrote: > > > you'll get a return value than can be interpreted as true or false > > ^^^^^^^^^^^ > > > > Bingo! I don't want to restrict the return values of question-mark > > methods to only true and false because I see nothing special about > > 'true' and 'false'. In my mind, they are just objects that just happen > > to have some useful equivalents when evaluated in a boolean context. > > And that's the key point here: context. > > > > Who cares what the type/class of an object really is, so long as the > > object can be *interpreted* in a meaningful way in the particular usage > > context? Sounds like the fundamental concept of duck typing to me. :-) > > I'm out of my league here (again), but I should mention that even > though we enjoy/love the flexibility of the Ruby language, that > freeness comes with a modicum of responsibility. > > If you start turning ? into a Fixnum (i.e. that's what the #whatever? > method returns), you've started to turn a duck in to a goose (or cat, > dog, whatever). Hey, whatever floats your boat... > > I can't think of one single reason for a variable/accessor to have a ? > on the end of it. I'll add more noise and clarify a little. I think James made a very succinct point. Useful at times, yes; should be baked into the language, umm, probably not. The ? trailing symbol can be seen several different ways. I tend to agree with others that it should give me something I can count on (TrueClass or FalseClass). If people want to mess with that ... I can adapt; no big deal. But, if you do, you kind of open pandora's box, because then we might have to start questioning every object before we can ask it to do something (be it true, false, nil, fixnum, string, etc). I'm willing to do that, but I don't think that is a healthy way to program. Todd