From: Tom Cloyd Date: 2009-01-05T11:38:33+09:00 Subject: Re: VERY simple question about "?" Robert Klemme wrote: > On 04.01.2009 14:48, Tom Cloyd wrote: >> I guess what confused me is that I bring to Ruby the notion that if a >> symbol causes something to happen, as "?" clearly does in my example >> (it produces the integer code for a character), > > In this case nothing "happens" (see below). It is just another > syntactical way to express an integer constant. > >> its' an operator or method. I'm not unfamiliar with linguistics. I >> don't see the equivalence between a string delimiter, or a character >> that signals the beginning of a symbol, and a symbol that is actually >> productive of something. Makes no sense to me at all, in fact. Maybe >> I'm failing to grasp some transformative concept which changes how >> things work in the Ruby world. >> >> Seeing operators as methods makes some real sense, on the other hand. >> "=" produces something out of what it's given. It doesn't just change >> meaning, which is all that happens with quotes or ":". That's the >> distinction I'm seeing, and it seems valid. > > I am not sure what you mean by "change meaning". Can you elaborate? Meaning, in linguistics as I understand it, is inherent, contextural, or both. "a" is inherently a character in the basic Roman alphabet used by many European languages. As a representation of a sound, its meaning changes depending upon context. Consider "pat" and "pate". Adding the suffix "e" to the consonant+vowel+consonant construction changes the sound of the "a". In Ruby, customer_count (a variable) and "customer_count" (a string) don't mean the same thing, because the latter has a prefix and suffix of the " symbol. Contextural meaning production is occurring. Ditto for the use of ":" in symbols. The """ and the ":" are context indicators, but produce nothing. Not so for "+" in "a+b" or, I think "?a". Something is emitted, here. That goes well beyond mere contextual meaning production, which is also occurring, to be sure. I hope I'm being clear enough here. > > Btw, note that there are two types of "=": > > 1. variable assignment as in "a = 123", > > 2. method call that mimics variable assignment as in "a.foo = 456". > > Both evaluate always to the right hand side - but this is about the > only commonality. Semantics of type 1 is fixed while you are free to > implement type 2 in any way you like, e.g. > > irb(main):005:0> a = Object.new > => # > irb(main):006:0> def a.foo=(x) puts "bah!" end > => nil > irb(main):007:0> a.foo = 456 > bah! > => 456 > irb(main):008:0> Thanks! That's fun, and interesting. > >> I'll keep thinking about it. > > Basically "?a" is just another textual representation for the integer > 97 which happens to be the ASCII code of character "a". It differs > from string delimiters because the expression "foo" is actually a > String constructor - it will create a new String object whenever it is > executed: > > irb(main):003:0> 3.times { x = "foo"; puts x, x.object_id } A "textural representation" that PRODUCES something? Doesn't make sense to me. Representations simply represent. They "stand for" something else, and do no more. Now, I can define method X, and then say that X "stands for" the method specification. That's true, from the compiler's point of view, among other things. But to say no more is misleading. "X" can be called, at which point it ACTS. "Tom" - my name can also be called, but when one does so IT doesn't spring into action at all. I might, but IT cannot. There is, I therefore assert, a fundamental difference here, and I think you're seeing that two different things have the same feature and concluding from that that they are the same sort of thing. That argument is obviously flawed. "It's incomplete, as my "Tom" demonstrations shows. You say "Basically "?a" is just another textual representation for..." - I'd agree, except for that "just". That single word makes the statement incorrect, to my mind, and also reveals the problem I'm addressing. > foo > 1073491940 > foo > 1073492040 > foo > 1073491880 > => 3 > irb(main):004:0> > [...] Thanks for your thoughts. I appreciate your sharing them. 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) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~