Re: RM and abstract syntax trees

From: David BL <davidbl_at_iinet.net.au>
Date: Mon, 12 Nov 2007 18:37:00 -0800
Message-ID: <1194921420.429291.93520_at_k35g2000prh.googlegroups.com>


On Nov 13, 6:36 am, "David Cressey" <cresse..._at_verizon.net> wrote:

> Where I disagreed with David BL was whether the data item (OID) that is
> used to stand for a pointer really is a pointer.

I want to describe another perspective on this. Consider the following C++ class

template <class T>
class ptr
{
public:

    ptr<T>& operator=(ptr<T> rhs);
    bool operator==(ptr<T> rhs) const;
    T& operator*() const
    {

        if (!p) p = LoadObject(oid);
        return *p;

    }
    T* operator->() const;

private:

    OID oid;
    mutable T* p;
};

The ptr<T> class is regarded as an ADT that implements all the operations expected of a pointer type.

A useful idea in C++ is to write parameterised data structures and algorithms to make them as general as possible. In particular it is possible to parameterise on the pointer type. This makes it possible for example to define double linked lists only once and either use direct memory pointers or else the above ptr<T>, or any other pointer implementation that one may have.

This means for example, that an algorithm that walks along the double linked list can (without knowing it) be automatically loading nodes into memory. It may also be binding to objects that are already found to be resident in a memory cache. The great thing about C++ is that the same code can be compiled in different ways, so you get type safety, flexibility and performance.

The point I want to make is that the ptr<T> deserves to be thought of as a pointer irrespective of how operator*() is implemented. The OID could be a physical OID or a logical OID - it doesn't matter.

You appear to want the definition of "pointer" to depend on how operator*() binds to the pointed at object (cf distinguishing "content" addressing). This is at odds with the whole idea of abstract types, so I reject your restricted notion of pointers. Received on Tue Nov 13 2007 - 03:37:00 CET

Original text of this message