[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ADT Lib: Persistence
Here is my current idea for the syntax of externalized objects. Most
of it is from ETH report 156, plus Stewart's suggestion about
provisions for `Alien' objects as in Oberon/F.
file = {object}.
object = NUM(ref) [ objdescr ].
objdescr = module type
LONGINT(offset) {data object LONGINT(offset)} data.
module = {char} 0X.
type = {char} 0X.
`ref' is a unique reference number assigned to an object when it is
externalized. The first occurrence of a reference number is followed
by the object's qualified type name, and the object's value.
`data' is a sequence of bytes (possibly empty), produced by calling
`Store' on a object. The sequence does not contain any embedded
objects.
`offset' is an integer number noting the offset from the rider
position just after the offset data, to the next occurrence of an
object embedded in the file. If it is non-negative, it refers to the
position an object that is referenced by the current object, if it is
negative, its absolute value minus 1 refers to the position of the one
after the current object.
The values for `offset' are inserted by back patching. If a piece of
`data' is written, its preceding `offset' value is set to point after
the data. This means that data of this format cannot be sent over a
pipe or a TCP stream without storing it in a file first. Because the
`offset' values are only needed to support `Alien' objects, it might
be useful to define a second format, that omits the `offset' data
altogether. The two formats could be distinguished by prefixing the
object sequence with a format id, and could be selected by an
additional parameter of `ConnectReader'. Does any one second this
proposal?
While all of this is pretty straightforward, I have my problems with
this procedure:
"PROCEDURE (VAR r: ObjectReader) TurnIntoAlien (cause: INTEGER)
This causes the currently Internalized store to become Alien."
See Stewart's mail for an example how this procedure would be used.
Does anyone have a brilliant idea how we can implement it in a simple
way?
-- mva