class_name(+instance, ?atom_name)

This built-in predicate determines the class name of an instance of a class. Tthe first argument must be a variable that refers to an instance and the second argument must be a variable or an atom. The class name of the instance is unified with the second argument. If the match succeeds then the predicate is exited, else it fails. If the first argument is not an instance of a class then class_name/2 fails.

see also: add_callback/3 add_callback/4 callbacks clear_var/1 del_obj/1 get_instance/2 instance/1 new_obj/2 new_obja/2  ispresent_callback/4 object-oriented prolog remove_callback/4 <-/2 ::<-/1 ::<-/2 this/1

Examples
X new_obj teststack,
class_name(X, Name).
the variable X refers to the instance and the name of the class is unified with the variable Name, the predicate will be exited.
Name = 'teststack'
X new_obj teststack,
class_name(X, stack).
the classname of the instance and the name 'stack' are not equal so the predicate fails

 

Exceptions
the second argument is not an atom nor a variable a type_error(atom, Arg) exception is thrown, the variable Arg is replaced by the incorrect argument

 

 

info@trinc-prolog.com