-var new_obj +class_name

This operator is used for creating new class instances, the left operand of this operator must be an empty variable and the right operator must be a class name or a non-empty variable. The default name of the instance is the name of the class, the name of the instance can be changed by using the operator obj_name/2.

The new instance is asserted to the current module as the last predicate of the module, just like assertz/1. The operator new_obja/2 also creates a new instance but the new instance is added to the module as the first clause of the module.

see also: add_callback/3 add_callback/4 callbacks class_name/2 clear_var/1 creating new instances del_obj/1 get_instance/2 instance/1 new_obja/2  ispresent_callback/4 object-oriented prolog obj_name/2 remove_callback/4 <-/2 ::<-/1 ::<-/2 this/1

Examples  
File new_obj menu if the new menu instance was created then it was assigned to the empty variable File

 

Exceptions  
left operand is not a variable a type_error(variable, A) exception is thrown, and A is replaced by the value of the left operand.
left variable is not empty an instantiation_error expression is thrown.
right operand is an empty variable an instantiation_error expression is thrown.
right operand is not an atom a type_error(atom, A) exception is thrown, and A is replaced by the value of the right operand.
there is no active module an existence_error(active_module) exception is thrown
unknown prolog class an existence_error(class, A) exception is thrown and A is replaced by the unknown class name
the prolog class is an abstract class an type_error(abstract_class, A) exception is thrown and A is replaced by the name of the abstract class
an internal error creating the new instance an allocate_error(instance, A) exception is thrown and A is replaced by the name of the class

 

 

info@trinc-prolog.com