Entry (main) method inside a class?

Stewart Gordon smjg_1998 at yahoo.com
Sun Mar 18 08:07:44 PDT 2007


Daniel Keep Wrote:

<snip>
> This is speculation, but I think that UNIX hard links are like...
> ref-counted objects in Python, 
<snip>

I'm not familiar with Python, but ref-counted objects is correct.  On Unix there are three aspects to a file: the path (hard link), the inode and the contents.  A hard link points to an inode, which contains the reference count; the inode in turn points to the file contents.  No two inodes can point to the same contents, but a given inode can have many hard links to it.

Interesting fact: The Unix rm command, in at least some versions, has a flag to zero the file's contents.  (Well, it either sets all bits to 0, then 1, then 0, or the other way round, I'm not sure which.)  But it doesn't check for multiple hard links, and so any that remain will just point to the blankness it has created.

I once wrote a C++ vector class that works in much the same way - having a class Vector, which the user works with, and VectorData, which stores the data itself and the reference count.

Stewart.



More information about the Digitalmars-d mailing list