Contract| Return type | wob | | No input parameters. | | Water Contract<method to_cxs/> | |
Returns a string representing the object in _subject that can be read back in to
recreate the object.
If to_path returns a string when called with a subject, then that string is returned.
Otherwise, to_cxs is called to make a full representation of the object.
If to_cxs is passed an instance that has fields containing other instances,
they will all be printed out in full.
If an instance appears more than once in the nested object being printed out,
then a representation is printed that, upon being read back in,
will have just one object at both locations. This is sometimes referred to
as the ability to do "circular printing", since an object can be printed that
has itself as a value of a field.
Unlike to_cxs, to_cxs will make a path for the top level object if it can.
to_xml makes an XML 1.0 syntax of an object whereas
to_cxs makes a less verbose, more programmer friendly representation
that's still very similar to pure XML.
number.<to_cxs/>
"number" <thing weight=246/>.<to_cxs/>
"<thing weight=246/>"
When printing the object it is called with, it tries to print a full representation of the object.
For instance,
when given a method it will print out the full source code
of the method, not just a path to the methodwhen given a cached instance, it will print out the full representation
of the object, i.e. all its fields. Values of the fields will be printed
with to_cxs so those may be printed as paths. when given a class, it will print out the source code of the class,
any methods in the class, any cached instances, and do the same for
any subclasses recursively on down.tries hard to print circular references a la to_cxs so that
An object that appears more than once in the tree will be represented by exactly
one object once the result of to_cxs is executed.
<class foo id=req subfoo=opt/>
<foo "xx" <foo "yy"/> />.<to_cxs/>
 | '<foo id="xx" subfoo=<foo id="yy"/>/>' |
Example: save an object to a file
<file "datafile.cxs"/>.
<set content=<foo "xx" <foo "yy"/> /> /> Example: Read back in and convert into an object
<execute source=<file "datafile.cxs"/>.content />
 | <foo id="xx" subfoo=<foo id="yy"/>/>
|
Example: Use the shortcut of execute on a file
<file "datafile.cxs"/>.<execute/>
 | <foo id="xx" subfoo=<thing.foo id="yy"/>/>
|
Calling execute will return the value of the last expression in the file.
But you won't really care since executing the file will side-effect
the appropriate classes by adding the cached instances to them.
© Copyright 2007 Clear Methods, Inc.