Flatten

To flatten an instance to a stream, use the global Flatten function. Flatten is more intelligent than >>= because it follows every pointer and nested instance contained in the original instance being streamed.

The reason Flatten is so important is that it maintains the correct instance structure when it is resurrected. If only pointers to instances are written to a stream, then during resurrection the pointers will end up pointing to unknown data. This is considered a run-time error, because accessing the pointers gives unknown results. To guarantee the resurrected information is exactly the same as the information that was flattened, all information about the instance is written to the stream.

When you use the Flatten function, instead of the more primitive >>= function, automatic optimization occurs. Flatten provides a default context, which recognizes when more than one of the same instance is present. By default, only the first instance is streamed out, and ID tokens are written for each similar instance streamed after the first. Writing only the tokens achieves a reduction in the amount of data streamed, thereby creating efficiency through data compression.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker