Re: VERY simple question about "?"



On 05.01.2009 03:38, Tom Cloyd wrote:
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,

Unfortunately we're in the domain of programming languages which is quite different from linguistics. Part of my difficulty understanding you is probably caused by the fact that you seem to try to tackle problems of computer languages with tools (terms and theories) from a complete different domain. While both domains happen to share terms I think it is not helpful to try to apply linguistics (i.e. the science of natural languages) to computer languages. It may actually hinder understanding.

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".

Actually I believe that "?a" does not belong in the same category as "a+b" because, as Dave and I have pointed out already, "?a" is just another way to write the integer 97 ("97", "0141" and "0x61" are other ways to write 97).

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:

A "textural representation" that PRODUCES something?

I did not mention "produce" in the context of - where do you take that from?

Doesn't make sense to me. Representations simply represent. They "stand for" something else, and do no more.

Yes, all these character sequences ("?a", "97", "0141" and "0x61") represent the Fixnum instance which in term is a technical representation (i.e. data) of the (mathematical) number 97. If an expression of a Ruby program is evaluate that contains any of these tokens, the token (which is an expression as well, more precisely a constant expression) evaluates to the said Fixnum instance.

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.

It does, as my example demonstrated. Opposed to "?a" "'Tom'" is not a constant expression but a String constructor. (See my example below which I took the liberty to put together again.)

There is, I therefore assert, a fundamental difference here, and I think you're seeing that two different things have the same feature and

Actually I pointed out that "?a" and "'Tom'" are not the same sort of thing. (On a certain level they are of course: both are valid syntax constructs (tokens) of the Ruby language. Actually, both are even expressions which happen do have different semantics - constant vs. non constant).

concluding from that that they are the same sort of thing.

Again, I do not know where you take that from. This is certainly nothing I have intended to convey.

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.

Not at all. There are many ways to write down 97 in a Ruby program (as I have shown above). In that sense "?a" is just another way to write it down (assuming "97" is considered the most commonly used way).

irb(main):003:0> 3.times { x = "foo"; puts x, x.object_id }
foo
1073491940
foo
1073492040
foo
1073491880
=> 3
irb(main):004:0>

Cheers

robert

--
remember.guy do |as, often| as.you_can - without end
.



Relevant Pages

  • Re: Numeric data in a CString object
    ... You have probably learned in other languages where characters and integers are different ... Any integer value can be compared to any character literal, ... my validating edit control; it also handles properly doing a paste. ... Finite State Machine to parse the string to see if it is really valid. ...
    (microsoft.public.vc.mfc)
  • Re: Problem with searching in TreeSet expressions starting with a given text
    ... Sorting is also working correctly in other languages. ... languages there can be additional letters. ... beginning with a given string. ... After all Character.MAX_VALUE might not be a valid Unicode character. ...
    (comp.lang.java.programmer)
  • Re: converting a string to a list
    ... format of the input data, ... languages is that you can treat the compiler as a black box, ... I input a string, the ... text character by character, or line by line. ...
    (comp.lang.lisp)
  • Re: What are SZ array?
    ... before Unicode and other languages such as VB came along. ... arrays of bytes, with each byte containing a character. ... string that it was 'null-terminated'. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Finding the alphabet in the soup
    ... though not Tom It's not that difficult :-) ... >>> I have variable string from which I want to extract from the left all>>> those characters up to before the second character that is an alphabet ... >>> However, in my case, all I know is that the character is any alphabet. ...
    (microsoft.public.excel.programming)