After instances have been created it is possible to save the module that contains class instances, the built-in predicates save_module/1 and save module/2 predicates can be used for saving a module. A stack instance that has the name 'stack' containing a single element that has been saved looks like:
| stack.stack([a], 1). |
By using open_module/3 the module can be loaded, if the compiler encounters a clause with type information in front of it, it starts searching for a class with the same name, if the class cannot be found then a compiler error is generated.
If the class declaration has been changed since the time that the instance was saved, for instance, the number of attributes was changed then the instance and the class are no longer compatible with each other. In these situations a compile error is generated but the instance is still loaded, not as a class instance but as a normal prolog clause.