Re: Objects and Relations

From: David BL <davidbl_at_iinet.net.au>
Date: 9 Feb 2007 15:55:25 -0800
Message-ID: <1171065325.802193.258360_at_v45g2000cwv.googlegroups.com>


On Feb 10, 1:45 am, "Kevin Kirkpatrick" <kvnkrkpt..._at_gmail.com> wrote:
> On Feb 9, 1:05 am, "David BL" <davi..._at_iinet.net.au> wrote:
>
>
>
>
>
> > On Feb 9, 12:32 pm, Bob Badour <bbad..._at_pei.sympatico.ca> wrote:
>
> > > Marshall wrote:
> > > > On Feb 7, 6:12 pm, "David BL" <davi..._at_iinet.net.au> wrote:
>
> > > >>On Feb 8, 6:26 am, Bob Badour <bbad..._at_pei.sympatico.ca> wrote:
>
> > > >>>>>Consider the following
>
> > > >>>>>void foo(Employee* p1, Employee* p2)
> > > >>>>>{
> > > >>>>> // Q1. What does this mean?
> > > >>>>> if (p1 == p2) ...
>
> > > >>>Conditional test whether p1 and p2 point to the same variable.
>
> > > >>Bob is confused about the difference between 'variable' and 'object'.
>
> > > > Objects are a specific kind of first-class variable. The term is not
> > > > popular in the OO world but it is nonetheless accurate.
>
> > > As Dr. Phil would say: David is levelling. To be perfectly accurate, p1
> > > and p2 point to memory locations. They could point to ROM or to memory
> > > mapped I/O devices. If they point to ROM, one could argue they point to
> > > something constant. That said, almost all memory locations address
> > > variables.
>
> > > However, 'object' has nothing whatsoever to do with the above. An
> > > instance of an object class is a variable. If the self-aggrandizing
> > > ignorant doesn't mean an instance of an object class when he uses
> > > 'object' above, he is actively trying to avoid communication.
>
> > object is the same as an instance of a class.
>
> > In common usage 'variable' is only used with reference to the
> > identifiers in the source that at run time are associated with an
> > instance of some type (whether a global variable, frame variable or
> > member variable). I'm not aware of a formal definition of variable,
> > but it's certainly unusual to say for example that allocating an
> > object from the heap is also said to be "allocating a variable".
>
> David BL: "I'm not aware of a formal definition of variable...".
> Perhaps it would behoove you to refresh you memory on the definitions
> of terms prior to criticizing the way others use them.

What I meant was that I wasn't aware that an agreed formal definition existed. I claimed that Bob confused variable and object because I associate 'variable' with something named in the source code in some scope, whereas Bob's usage allows for a variable to designate an area of memory without need for a direct binding back to a name in the source code.

In the following code

    Node* p = new Node;

I would say that p is the only variable (a variable on the frame). However Bob would appear to say that after a Node is allocated there would be another variable. So p is a variable and also points at a variable.

> A variable is a reference to a value. Variable declarations determine
> the scope of the variable as well as constrain (by domain, behavior,
> implementation, representation, or some combination thereof) the
> values that the variable can reference. Assignment is the association
> (or binding) of a variable with a specific value and dereferencing is
> retrieving the value associated with a variable. Allocation involves
> locating and claiming resources to hold the physical representation of
> values to which variables are bound.

Your definition is similar to my understanding. Bob seems to have a far more liberal usage that I've never seen before.

> Based on the above and using your definition "object is the same as an
> instance of a class", your phrase "allocating an object from the heap"
> is utterly incoherent.

Why? What's wrong with saying "allocate an instance of a class from the heap"?

In the following

    Node* p = new Node;

All the following are acceptable: "allocate an object", "allocate a Node object", or "allocate an instance of class Node".

> Naturally, the more general version,
> "allocating a variable", is also incoherent. This shared incoherence
> in no way advances your argument that objects are not a kind of
> variable (if anything, it constitutes evidence to the contrary).
>
> Had you prefaced your phrase with a clarification that data objects,
> unlike OO objects, refer to physical representations of a value;

What exactly is a "data object"? Does it have identity? If it does how can it represent a value?

> and
> then disambiguated the phrase "allocating an object from the heap",
> you would have arrived at the perfectly coherent "allocating a data
> object from the heap".

So a data object is not an object?

> Of course, this coherent version does not
> generalize into the incoherent "allocating a variable", so it wouldn't
> have advanced your argument either.

I was making the point that "allocating a variable" was incoherent (according to my understanding of 'variable'). However I think Bob would say that usage is ok.

[snip] Received on Sat Feb 10 2007 - 00:55:25 CET

Original text of this message