What is an object?

D

David Hopwood

Douglas said:
Not the same; a variable is capable of being modified,
while a constant object is not.

Variables may or may not be capable of being modified, depending on
the programming language. The term "variable" does not in itself connote
modifiability.

David Hopwood <[email protected]>
 
T

Tom Payne

In comp.std.c David Hopwood said:
Variables may or may not be capable of being modified, depending on
the programming language. The term "variable" does not in itself connote
modifiability.

I've not taught a course on principles of programming languages for
almost ten years, but the last time I looked at textbooks on the
subject, none of the used the term object in the sense that it is used
by the C and C++ standards. Rather, they defined a variable to
consist of some or all of the following:
- a name (in the sense of identifer)
- a memory location capable of holding a value (i.e., what C/C++
calls an object)
- a scope
- a lifetime
- a type.
Somewhere they implicitly or explicity spoke of anonymous (nameless)
variables, often with statements like "an array is a sequence of
variables indexed by a range of integers" -- visibly each of them
doesn't get its own name. So, what's a variable without a name? It
looks very much like what C/C++ calls an object.

I'm not saying that I prefer that terminology, but it's important and
often difficult to translate among the metalanguages for various
programming languages. Too often the same idea arises in multiple
computing contexts, each time with an different metaphoric
terminology.

Tom Payne
 
E

E. Robert Tisdale

Tom said:
David Hopwood <wrote:


I've not taught a course on principles of programming languages
for almost ten years,
but the last time I looked at textbooks on the subject,
none of them used the term object in the sense that it is used
by the C and C++ standards. Rather, they defined a variable to
consist of some or all of the following:
- a name (in the sense of identifer)
- a memory location capable of holding a value
(i.e., what C/C++ calls an object)
- a scope
- a lifetime
- a type.
Somewhere they implicitly or explicity spoke of anonymous (nameless)
variables, often with statements like "an array is a sequence of
variables indexed by a range of integers" -- visibly each of them
doesn't get its own name. So, what's a variable without a name?
It looks very much like what C/C++ calls an object.

I'm not saying that I prefer that terminology,
but it's important and often difficult to translate
among the metalanguages for various programming languages.
Too often the same idea arises in multiple computing contexts,
each time with an different metaphoric terminology.

Part of the problem may be that many of the people involved
in writing the standards documents have never had
any formal training in programming languages or compiler design.

Concepts like type, object and variable have always had
the same meaning across all computer programming languages.
This overloading [narrowing] of the meaning
of certain common terms to facilitate the definition
of any particular language standard causes confusion
among programmers who must master several programming languages.
 
B

Brian Inglis

One would be incorrect. Consider the usage of "variable" in mathematics.

Mathematical use of the word variable is irrelevant to its use in
programming in general, and C in particular. I'm sure the compiler is
free to optimize away the storage unless & is used.

Please enlighten us as to the contexts in which variables are not
considered to vary in mathematics.
 
B

Brian Inglis

Variables may or may not be capable of being modified, depending on
the programming language. The term "variable" does not in itself connote
modifiability.

Would one not then tend to refer to the variable as a constant or
parameter, even if the language itself supports no such concepts?
 
T

Tom Payne

Part of the problem may be that many of the people involved in
writing the standards documents have never had any formal training
in programming languages or compiler design.
Concepts like type, object and variable have always had the same
meaning across all computer programming languages. This overloading
[narrowing] of the meaning of certain common terms to facilitate the
definition of any particular language standard causes confusion
among programmers who must master several programming languages.

Many of the people involved in the C and C++ standardization efforts
were extremely knowledgeable of both the design and the implementation
of programming languages. The decision to use the term "object" for
what others (akwardly) called "anonymous variables" was probably made
in the mid eighties, well before "object-oriented programming" got to
be the pervasive notion that it is today. I can't criticize that
decision. I simply regret the confusion it causes.

Tom Payne
 
C

CBFalconer

E. Robert Tisdale said:
.... snip ...

Part of the problem may be that many of the people involved
in writing the standards documents have never had
any formal training in programming languages or compiler design.

I am extremely weary of this continuous retrolling of this silly
subject. For the purposes of C an object is fully defined in the
standard. No more need be said.

I suggest everybody PLONK this thread. Trollsdale has returned to
his obnoxious ways.
 
D

Douglas A. Gwyn

E. Robert Tisdale said:
Part of the problem may be that many of the people involved
in writing the standards documents have never had
any formal training in programming languages or compiler design.

How did you determine that? Anyway, most of the WG14
active participants certainly have had formal training
and experience in those areas.
Concepts like type, object and variable have always had
the same meaning across all computer programming languages.

Wrong.
 
D

David Hopwood

Brian said:
Mathematical use of the word variable is irrelevant to its use in
programming in general, and C in particular. I'm sure the compiler is
free to optimize away the storage unless & is used.

The use in programming is derived directly from the mathematical use,
and is not inconsistent with it. An instance of a mutable variable in
a programming language can be viewed as referring to a fixed "slot" or
"cell", which can have a value that changes over time.
Please enlighten us as to the contexts in which variables are not
considered to vary in mathematics.

Variables are never allowed to directly vary over time -- i.e. to be
mutable -- in mathematics. Different instances of a variable can take
different values.

Doug said:
> > [...] Consider the usage of "variable" in mathematics.
>
> As opposed to "constant"?

Yes. The difference between constants and variables is not that variables
are mutable, but that variables can have multiple instances.

David Hopwood <[email protected]>
 
S

SM Ryan

# The use in programming is derived directly from the mathematical use,
# and is not inconsistent with it. An instance of a mutable variable in

C is a bastard child of Fortran, Algol 60, and Algol 68. Algol 68 got
the terminology right. As usual, when C steals from Algol 68, it does
it in half-assed totally mucked up fashion. If you bothered to understand
the issue from Algol X, Algol W, and the rest, the whole notion of
lvalues and rvalues and references and dereferences and all the rest
would be much clearer.
 
J

James Kuyper

Tom Payne said:
doesn't get its own name. So, what's a variable without a name? It
looks very much like what C/C++ calls an object.


More accurately, an object can be a variable, or it can be nameless.
Variables are always named. In C++, they're defined by that fact
(3p4): _variable_ basically means "declared object", and you can't
declare an object without giving it a name. I couldn't find comparable
wording in the C standard, however.
 
R

Richard Tobin

SM Ryan said:
Algol 68 got the terminology right. [...]
If you bothered to understand
the issue from Algol X, Algol W, and the rest, the whole notion of
lvalues and rvalues and references and dereferences and all the rest
would be much clearer.

So clear in fact that none of us would feel the slightest urge to
write

real x = 1.2

instead of

ref real x = loc real := 1.2

-- Richard
 
D

David Hopwood

James said:
More accurately, an object can be a variable, or it can be nameless.

No. Consider an object that is referred to by two distinct variable
instances (e.g. instances of global variables with external linkage in
different translation units). This shows that variable instances
*refer to* objects; an object cannot *be* a variable instance (or a
variable).

David Hopwood <[email protected]>
 
K

Keith Thompson

More accurately, an object can be a variable, or it can be nameless.
Variables are always named. In C++, they're defined by that fact
(3p4): _variable_ basically means "declared object", and you can't
declare an object without giving it a name. I couldn't find comparable
wording in the C standard, however.

Because there is no such wording in the C standard. The C standard
doesn't define the word "variable", and uses it only a few times.
(The usage is consistent with a variable being a declared object, but
there's not enough basis to decide, for example, whether arr[3] or
*ptr are considered "variables" or not.)

I suggest that the meaning of the word "variable" isn't a fruitful
topic for comp.std.c, unless you want to propose defining it in a
future standard.
 
M

Mabden

CBFalconer said:
I am extremely weary of this continuous retrolling of this silly
subject. For the purposes of C an object is fully defined in the
standard. No more need be said.

I suggest everybody PLONK this thread. Trollsdale has returned to
his obnoxious ways.

Your continuous trolling every time ERT posts is beyond old. Why don't you
STFU if you don't have something to say.
 
T

Tom Payne

In comp.std.c David Hopwood said:
The use in programming is derived directly from the mathematical use,
and is not inconsistent with it. An instance of a mutable variable in
a programming language can be viewed as referring to a fixed "slot" or
"cell", which can have a value that changes over time.

My students claim to have been told by math teachers that:

- A variable is what you use when you don't know that you're talking
about.

- There are two kinds of numbers, constants and variables, and you
can tell which kind by whether its from the beginning alphabet
(constants) or the end of the alphabet (variables).

Tom Payne
 
E

E. Robert Tisdale

Tom said:
David Hopwood wrote:
[...]
The use in programming is derived directly from the mathematical use,
and is not inconsistent with it. An instance of a mutable variable in
a programming language can be viewed as referring to a fixed "slot" or
"cell", which can have a value that changes over time.

My students claim to have been told by math teachers that:

- A variable is what you use when you don't know that you're talking
about.

- There are two kinds of numbers, constants and variables, and you
can tell which kind by whether its from the beginning alphabet
(constants) or the end of the alphabet (variables).

According to the American Heritage Dictionary of the English Language

http://www.bartleby.com/61/

variable
NOUN: Mathematics
a. A quantity capable of assuming any of a set of values.
b. A symbol representing such a quantity. For example,
in the expression a^2 + b^2 = c^2, a, b, and c are variables.

constant
NOUN:
a. A quantity assumed to have a fixed value
in a specified mathematical context.
b. An experimental or theoretical condition, factor, or quantity
that does not vary or that is regarded as invariant
in specified circumstances.
 
D

Default User

Mabden said:
Your continuous trolling every time ERT posts is beyond old. Why don't you
STFU if you don't have something to say.


I would plonk you right now, but I'm changing newsreaders soon. Remind
me (probably by saying something stupid) to plonk you later.




Brian Rodenborn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top