[cap-talk] Objects and Facets
Eric Northup
digitale at digitaleric.net
Wed Aug 2 09:19:32 EDT 2006
On Aug 2, 2006, at 8:23 AM, Neal H. Walfield wrote:
> On the Hurd, we have the following: a file consists of its contents
> and some meta-data. When a user calls "open", the file server doesn't
> simply return a capability naming this state; it first allocates some
> memory to hold, among other things, the position of the cursor in the
> file and returns a capability naming that state. This state is
> private to each open.
>
> In the language of capabilities, what would be the file object here?
> Is it the shared state and the private state? (If so, is the shared
> state also a separate object from this conglomeration of the shared
> state and the private state?) Is it the private state with the
> addition of a capability naming an object encapsulating the shared
> state? In short, what's the right way to talk about these things?
It seems to me that, in the design you presented above, there are two
distinct objects.
The second one, an OpenFileHandle, responds to requests like read(),
write(), seek(), tell(), close(), etc. The OpenFileHandle object has
access to state representing all the bytes of the file, and also the
per-session state like the cursor position.
The first one responds only (?) to the open() operation, and returns
OpenFileHandles. So it might be considered a "factory" object,
OpenFileHandleFactory. This object has access to the state representing
the bytes of the file, although it is not necessary that it use the same
representation as the OpenFileHandle uses.
It might be worth considering that *all* the object state described is
"private", from their clients in the sense that the objects do not share
it freely with clients. Instead, the objects expose accessor methods to
manipulate the state. The fact that some state is shared between
different OpenFileHandle instances doesn't make it any less private to
the clients.
I would not consider them two facets to a single object, because I think
the factory object is mostly a wrapper (perhaps an EROS Contructor /
KeyKOS Factory) around a second type of object. So their top-level
message processing event loops are different. I would consider
ReadOnlyOpenFileHandle / AppendOnlyOpenFileHandle /
ReadWriteOpenFileHandle to be different facets of the same object.
But the OpenFileHandleFactory and the OpenFileHandle could be
implemented in a way such that they are two facets to the same event
loop. In that case, I would consider them to be different facets.
Fair warning: I make no claim that the above is the right way to talk
about these things, it's just the way I think about them.
-Eric
More information about the cap-talk
mailing list