[gclist] Reference counting on the fingers of one thumb.

John Carter john@dwaf-hri.pwv.gov.za
Thu, 30 Jan 1997 14:19:59 +0200 (SAT)


Sorry for starting a debate and then taking two weeks holiday..., but
I'm back and plaguing the world again...

On Thu, 23 Jan 1997, Amit J Patel wrote:

> [My reply is a little late!]
So is mine... 

I am glad that there are at least some other people around the world
that don't believe that language design is a "solved problem". Those
who believe that there is life beyond existing languages are a rare
breed these days...

> I can't agree with this.  When I'm trying to mimic the spatial world,
> I have to eliminate copying.  I can't copy myself; I can't copy my
> office; I can't copy my car.  A few objects (such as papers and disks)
> allow copying, but copying them is not a primitive operation, so I
> don't mind if the language does not support copying objects.  

My first response was to sputter and fume, my second response is to
say yes, you are quite right. I should make := mean handover, and have
"deepcopy" as a function call or something. I knew that asking the net
for comment would save me from many fundamental blunders.

> I view names (variables) as references to objects, not the objects
> themselves.  

Yes, that is the normal view of them. I wish to move to a view of "If
I have its name, I have it in my hand. If I have it in my hand, I can
do something with it." In the spatial world, we can reach out and pick
up an object and do something with it. In the computer world, the
variable names are the "hands" in which we hold the objects we operate
on.

The normal situation, and the reason for much of the need for GC, is
that we can have arbitarily many "hands" holding the same object.

> I would like to page you without knowing which container you are in.
> I want an alias for you that doesn't involve knowing where you are.

There is nothing to stop you putting everyone in the container called
"global_heap", and working with integer indices thereafter. This is
exactly back to ye olde C pointers. The point is the default behaviour
in C is unsafe, but you can make is safe. I propose to make the
default behaviour safe, but you can explicitly make it unsafe.

> Another example is a program accessing some file on the disk.  If I
> move the file into a different folder, I want that program to still
> access the file; it shouldn't have to know that the file has 'moved'.
> (Most OSes don't give you this, unfortunately.)
In Linux "mv old.name new/place;ln -s new/place old.name". But I
really wouldn't like that to be the default behaviour of move.

> > Now the integer index of the object in the container provides all the
> > functionality of a traditional pointer, but in a local, not global
> > namespace. It is also just a plain old integer, and hence is amenable
> > to all the fun things one can do with integers.
> 
> What fun thing would you like to do with this integer?  :)  I can't
> think of anything really useful to do with it.  If I have a reference
> to you (your room + your integer), does it help to multiply your
> integer index by four?  

Yes, if you know that every fourth person in the room, (as numbered),
is an elligible person of your sexual orientation.

In C you can do fun things like trot up and down arrays with pointers
in arbitary steps. Pascal pointers are boring. You can only follow
them. 

If you have two structures "in sync" with each other, you can transfer
the integer offset of the one pointer to access the corresponding
object in the other structure. The notion of correspondence is quite
universal. 

Admittedly these practices are unsafe, that is why I have doubts
about it.

> I would also like to have containers that have references (aliases) to
> other objects.  For example, a list of all the books that I own.  Do I
> need to store a pair (room, index) for each book?  What if the book
> moves?  Why should my list have to change?  The traditional
> pointer/reference model is good for things like this.

Yes. It is good at creating complex webs. But complex webs are unsafe,
and can be represented in other ways. Look to the database
world. Databases once were hairy things that created complex webs of
pointers. Now no one will even admit that their database isn't
relational. (Even if it isn't). The relational model has won
overwhelmingly. Think of your example above in terms of building a 4th
normal form database. A notable feature of a 4th normal form database
vs the old all-in-one-with-pointers-everywhere is the proliferation of
smaller tables (relations), with entries that are indices of some form
into another small table.

> I think it'd be nice to have a language that distinguishes two kinds
> of variables -- "contains" and "refers to".  

How about one of ("contains" and "contains reference to") or ("refers
to" and "refers to container") to orthogonalize the language. My
proposal is the "contains" and "contains reference to" flavour.

> Have you done any more designing for your programming language?

If you are interested, I can private email some other scribblings to
you for comment. I'm very much at the conceptual design / analysis of
existing designs / reading stage, rather than implementation.


John Carter                    EMail: ece@dwaf-hri.pwv.gov.za
Telephone : 27-12-808-0374x194 Fax:- 27-12-808-0338

Founder of the Council for Unnatural Scientists.