The operator unique_name can be used to give each new instance a different and unique name. The name will be generated by Trinc-Prolog and is guaranteed to be unique and its type is atom. The generated name is unified with the empty variable to the right of unique_name/2.
This operator can only be used while creating a new instance with the operators new_obj/2 or new_obja/2.
see also: new_obj/2 new_obja/2 object-oriented prolog
| Examples | |
| X new_obj stack unique_name N. | a new instance of the class 'stack' is created and the unique
name assigned can be something like: N = o18708708 |
| Name='my_name', X new_obja menu unique_name Name. |
an exception is thrown because the variable 'Name' is not empty at the moment 'new_obja' is proven |
| Exceptions | |
| right operand of unique_name/2 is not an empty variable | a type_error(variable, Arg) exception is thrown |