int main(void)
{
int a;
a = 6;
return 0;
}
Is 6 an identifier? If so, does it identify the object with the actual
value? In this case, the actual value on my system would be 0x00000006.
(1) No. (2) From "if false," all conclusions follow.
--
Eric Sosman
eso...@ieee-dot-org.invalid
Perhaps I'm over complicating this, but doesn't 6 represent something?
Like maybe an object? Here is what I mean. Let's say I have the
following sequence of C code...
char *p;
p = malloc(6);
free(p);
Doesn't 6 have to represent or identify something in order for malloc
() to allocate the appropriate space?
> On Nov 22, 6:10 pm, Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
>> Chad wrote:
>> > Given the following C program...
>>
>> > int main(void)
>> > {
>> > int a;
>> > a = 6;
>>
>> > return 0;
>> > }
>>
>> > Is 6 an identifier? If so, does it identify the object with the actual
>> > value? In this case, the actual value on my system would be 0x00000006.
>>
>> (1) No. (2) From "if false," all conclusions follow.
>>
>
> Perhaps I'm over complicating this, but doesn't 6 represent
> something?
Yes, it represents 6. I think you are over complicating it.
> Like maybe an object?
No, object has a well-defined meaning when talking about C. An object
(in C) is a region of storage. It is made up of bits that can be used
to represent values.
> Here is what I mean. Let's say I have the
> following sequence of C code...
>
> char *p;
> p = malloc(6);
> free(p);
>
> Doesn't 6 have to represent or identify something in order for malloc
> () to allocate the appropriate space?
If you want to names things, p is an identifier that names an object.
6 is an integer constant the represents 6. It is part of an
expression statement (p = malloc(6);) the effect of which is to
allocate another object with dynamic lifetime and store a pointer to
this new object in p.
--
Ben.
Sure, 6 represents '6 bytes'.
--
Do they only stand
By ignorance, is that their happy state,
The proof of their obedience and their faith?
Yeah, I guess I like to have things named for me. It helps me when I
read some of the terse responses to other peoples questions on this
forum.
Hmm... That response sound kind of awkward.
And yes, that was me talking to myself.
(a) is the identifier of an object.
(6) is the value that (a) has after the assignment operation.
How that value gets in there, is unspecified by the standard.
The code does not imply that there is an entity with a value of (6)
prior to the assignment.
(6) means the exact same thing as (3 + 3).
--
pete
> int main(void)
> {
> int a;
> a = 6;
>
> return 0;
> }
> Is 6 an identifier?
No.
An identifier is just a fancy word for a name, and identifiers are things
which start with an underscore or a letter, followed by underscores, letters,
and digits.
> If so, does it identify the object with the actual
> value? In this case, the actual value on my system would be 0x00000006.
That is not what "identifier" means. An identifier is, again, a name. It
has nothing to do with values.
-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
> On 2009-11-23, Chad <cda...@gmail.com> wrote:
>> Given the following C program...
>
>> int main(void)
>> {
>> int a;
>> a = 6;
>>
>> return 0;
>> }
>
>> Is 6 an identifier?
>
> No.
>
> An identifier is just a fancy word for a name, and identifiers are things
> which start with an underscore or a letter, followed by underscores, letters,
> and digits.
>
>> If so, does it identify the object with the actual
>> value? In this case, the actual value on my system would be 0x00000006.
>
> That is not what "identifier" means. An identifier is, again, a name. It
> has nothing to do with values.
>
> -s
Clearly nonsense since it has a very close connection to values : its
how people USE those values.
int i =j;
Are you saying j does not have a value?
Don't try to be too clever : it ends up in language wars.
--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c
>> That is not what "identifier" means. An identifier is, again, a name. It
>> has nothing to do with values.
>Clearly nonsense since it has a very close connection to values : its
>how people USE those values.
>
>int i =j;
>
>Are you saying j does not have a value?
I think you're reading to much into "nothing to do with values". Of
course j has a value, but presumably the OP is concerned with the
technical meaning of the terms, otherwise he wouldn't be asking
whether 6 is an identifier. From that point of view, j is an
identifier denoting an object whose value is 6. Not all identifiers
denote objects, so they don't all have values (a label for example).
-- Richard
--
Please remember to mention me / in tapes you leave behind.
Yes: It represents a value. But it's still not an identifier.
> Like maybe an object?
No. If there were an object, you could form a pointer to that
object and pass the pointer around. But you can't: The 6 merely
denotes a value, and says nothing at all about how that value comes
to life in the program.
Some implementations may actually allocate an int-sized piece
of memory containing the value 6, and read from that "invisible
object" when the value is needed -- but that's just the system's
own way of getting things done, not an implication that there's an
actual object floating around. Other implementations may have a
more economical way of generating small integer values, like an
"immediate operand" taking less than an int's worth of memory,
so there's not even an int-sized piece of storage to look at if
you could peer behind the curtain. You write 6, the implementation
works some kind of magic, and the value six shows up. That's all.
> char *p;
> p = malloc(6);
> free(p);
>
> Doesn't 6 have to represent or identify something in order for malloc
> () to allocate the appropriate space?
Yes: 6 represents the value six, with type int. Assuming
all is well, this value will then be converted to the value six
with type size_t, and that's what malloc() will receive as an
argument. The conversion from int to size_t may well happen at
compile time, so that an int six never even exists at all when
the program runs. And, as before, this doesn't mean that there's
a size_t-sized piece of memory somewhere that holds a six; the
implementation delivers the six to malloc() by whatever means
it chooses.
--
Eric Sosman
eso...@ieee-dot-org.invalid
Note that merely matching the syntax does not qualify a
source token as an identifier. For example, `break' and `int'
and `const' are not identifiers.
--
Eric Sosman
eso...@ieee-dot-org.invalid
Identifiers are names of values. In *some* sense, a number is some abstract
thing that can be named in different ways:
6 arabic numerals
VI roman
six english
seis spanish
sechs german
schesch hebrew
1010 binary base
All those are "identifiers" of the abstract number. But in C, a numeric
constant is not an identifier.
'6' is an integer constant expression, not an identifier. It cannot
serve as an lvalue; you can't assign to it, you can't take its
address, you can't apply operators like ++ or -- to it, etc. Whether
it's associated with a distinct block of memory is an implementation
detail; for small values like this, it's probably encoded as an
immediate operand in the instruction.
Sure.
typedef int iden1;
stuct ident2;
Identifiers are names, but not necessarily of values.
An identifier is a syntactic construct, a particular kind of token,
nothing more, nothing less.
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
> >> Given the following C program...
>
> >> int main(void)
> >> {
> >> int a;
> >> a = 6;
> >> return 0;
> >> }
>
> >> Is 6 an identifier?
>
> > No.
>
> > An identifier is just a fancy word for a name, and identifiers are things
> > which start with an underscore or a letter, followed by underscores, letters,
> > and digits.
>
> >> If so, does it identify the object with the actual
> >> value? In this case, the actual value on my system would be 0x00000006.
>
> > That is not what "identifier" means. An identifier is, again, a name. It
> > has nothing to do with values.
>
> Clearly nonsense since it has a very close connection to values : its
> how people USE those values.
>
> int i =j;
>
> Are you saying j does not have a value?
you don't initialise it so it doesn't have a value
> Don't try to be too clever : it ends up in language wars.
:-)
Who told you that?
Of course it has a value.
It MIGHT be an "undefined" value. But a value it is.
I did not think a compilable support framework was really necessary for
such a simple example.
> Chad wrote:
> > Perhaps I'm over complicating this, but doesn't 6 represent something?
> > Like maybe an object?
>
> No. If there were an object, you could form a pointer to that
> object and pass the pointer around. But you can't: The 6 merely
> denotes a value, and says nothing at all about how that value comes
> to life in the program.
>
In C you can't form a pointer to an object with register storage
class. On most matchines ff it actually is in a register, it is not
possible to have a pointer to it (there are a few exceptions). But C
makes the prohibition uniform; even if the compiler chooses to put a
'register' object in memory, you still can't take & of it.
The defining characteristic of objects is storage. For objects that
are mutable, you can observe change in state i.e. contents. But C also
has const objects, which you can't change. In a philosophical sense,
const register objects aren't distinguishable from values.
> Some implementations may actually allocate an int-sized piece
> of memory containing the value 6, and read from that "invisible
> object" when the value is needed -- but that's just the system's
> own way of getting things done, not an implication that there's an
> actual object floating around. Other implementations may have a
I'd say there is not a *C* object. There is a kinda-sorta-object.
For example, S/360 et seq did this so much that the assembler had
convenient syntax for it:
Load R3, =W(123)
assembles a word of data elsewhere (initially) containing 123, and a
code instruction (inline) that loads from that word of data to R3.
> more economical way of generating small integer values, like an
> "immediate operand" taking less than an int's worth of memory,
> so there's not even an int-sized piece of storage to look at if
> you could peer behind the curtain. You write 6, the implementation
> works some kind of magic, and the value six shows up. That's all.
>
And sometimes two (or perhaps more) pieces, e.g.
LoadHI R3, 0x12
LoadLO R3, 0x3456
to give you 0x123456 in the register without any contiguous storage
containing 0x123456 (in whatever endianness applies).
And sometimes no storage at all. Quite a few machines have 'hardcoded
zero' as one of the register choices, and I've heard of some that have
a few others like -1 (equivalently ~0 in 2sC as is now most common).
The PDP-8 had microcoded* operate instructions that could generate a
small and rather eclectic set of values with no data word (which was
precious; you got at most 125 in current page and 128 minus
reservations in zero page) and no data fetch (also precious).
6 happens to be among them, using CLA INC STL RTL .
I no longer remember the encoding for this (and am not going to bother
looking it up) but I'm confident it doesn't resemble 6 *at all*.
(* sort of VLIW style, for extremely small values of large, about
15-20 years before that terminology came into use)
<snip rest>