From: Tom Cloyd Date: 2009-01-05T15:42:41+09:00 Subject: Re: VERY simple question about "?" Dave Thomas wrote: > > On Jan 4, 2009, at 8:14 PM, Tom Cloyd wrote: > >> I'm still struggling here. When syntax is productive of something, I >> see an operation occurring - active functionality. I'm perfectly >> content to see operators as methods. Syntactically there's no problem >> that I can detect in that construct. But to call "?" a >> literal...well, I must go study up a bit on this. To me, "abcdef" is >> a literal. '\n' is too. "\n" is a literal if you allow meaning to be >> contexturalized, which should be no problem. As input to various >> processes, '\n' and "\n" have different outcomes, but by themselves >> produce nothing. "?" produces something. Irb makes this clear >> (to me): >> >> irb(main):006:0> puts '\n' >> \n >> => nil >> irb(main):007:0> puts "\n" >> >> => nil >> irb(main):008:0> puts ?\n >> 10 >> => nil >> irb(main):009:0> >> >> If in "-1", we consider the "-" to be an operator, then I see an >> exact parallel to the function of "?a". >> >> It's not the same as what quote marks do - THEY provide context, and >> change meaning. Operators PRODUCE something. They "operate". It seems >> very simple. If I'm making a fundamental error, I'd be very grateful >> to have it point out to me. I highly value arriving at a place of >> clear understanding, when it's possible > > I think you're over thinking it. For example, in > > 0x10 > > which is 16 in decimal, is the '0x' part an operator? If you say no > (which I hope you do) then why would you say that ? is an operator in > ?a (which is 97). They are simply characters that are used by the > lexical analysis phase to help interpret what follows. No executable > code is generated: there's no operation. > > Similarly, in your example of -1, the - sign is NOT an operator. It > simply means that when parsing the constant, a negative value is > required. Again, so executable code is generated. That's the > difference between > > a = -1 # -1 is a constant, no operator > b = -a # the unary minus operator (-@) is invoked on the > object referenced by a > > Cheers > > > Dave > > > > Thanks, Dave. This helps. You have a genuine knack for simple clear statement and example. Thanks for the dialog! t. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc@tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~