| Did you know ... | Search Documentation: |
| Send methods |
Normally invoked through the Prolog predicate checkpce/0.
Diagnostics: See related error objects
->for_slot_reference <-_class
->free<-_class
<-_class->initialise
and hyper->unlink.
These methods should never be called directly by the user. It is
however possible to redefine these methods to intercept the creation and
destruction of hyper-links. A redefinition should
always call this method.
->delete_hypers.|name,
value=[any]An error is raised if the class already defines an instance variable with the same name.
->popup <-all_attributes <-convert <-object if the
current save version is not the same as save version when the file was
loaded. The two arguments are the old and the new save versions. See pce<-save_version.
->initialise_new_slot|attribute->attribute.
Fails silently if the attribute is not present.
Diagnostics: Fails (silently) if the attribute is not defined.
->attribute<-find_hyper
for the interpretation of the name and condition arguments...... get(Area, size, Size), .... send(Size, done).
The receiving object will be deleted from the object base as with object->free
if the receiver has no object<-references, object<-lock_object
is @off and
object<-protect
is @off.
In the example above object->done
is equivalent to object->free
as the size object
returned by area<-size
is created by this method (provided the .... computation does not lock,
protect or make the size an attribute of some other object. In the
example below, using object->free
will corrupt PCE's database:
.... get(Graphical, area, Area), .... free(Area). % ==> ERROR!!!
The area object will
be deleted and the slot graphical<-area
will be pointing in the dark (checkpce/0
will find such problems).
Using object->done
is often not necessary. After a user-event has been processed all
unreferenced and unlocked objects will be deleted from the object base
automatically. Unreferenced objects created during the execution of a
user-defined method for a PCE class are also deleted automatically. object->done
is useful when a lot of garbage objects are created in a loop.
<-lock_object->same_reference.
Bugs: The notion of equality is not very clear in PCE.
\== <-id
and converted by error<-convert)
is the error to be raised. The remaining context arguments provide
context information about this error. Performs the following steps:
<-kind
equals ignored, silently fail.<-last_error.->catched),
it invokes
error->display
on the error object.
See also class error
and object->report.
Diagnostics: Diagnostics depend on the error object invoked.
->report ->catched -idFor each slot-reference, code is executed with the following bindings:
@arg1 The instance @arg2 Type of slot reference @arg3 The slot @arg4 The value of the slot
The Type of slot reference is one of:
->free
performs the following steps:
->unlink.
This allows a class to unlink the object from the environment.<-references.
Otherwise reclaim is delayed. See pce<-deferred_unalloced.
object->unlink
is often defined on objects that need to inform some other object that
they are destroyed. For example, graphical
objects inform their device to allow the device to remove the object
from the display and update their book-keeping.
The method object->unlinking
is provided as a test whether or not object->free
is in progress on the receiver.
See also visual->destroy
to destroy entire hierarchies of (visual) objects.
Diagnostics: Fails silently if object<->protect
equals @on.
Bugs: Window object->free
should just delete the window from it's object<-frame.
In new code, please delete frames using object->free.
->unlink ->destroy ->protect ->destroy ->_free|chain->get_class.
<-get_class <-slot <-all_get_methods ->send_method ->get_method <-get_method, object<-send_method}
returns a value but avoids the creation of a tuple. See also
class<-send_method
and class<-get_method.<-name returns @off.<-name returns @on.<-name not-equal 2nd
argument.<-Name and
compare the result to the argument. Succeed if they are equal (have same
reference), fail otherwise.
This method is intended to test on attribute values. Similar and more
powerful results can be obtained using class ==.. It's usage is to be
preferred. The following code
objects and Prolog fragments all test whether the point<-x
of the point object @p
equals 3:
Prolog:
get(@p, x, 3) % Uses Prolog unification send(@p, has_value, x, 3)
Code fragments:
message(@p, has_value, x, 3) @p?x == 3
object->not_has_value
is equivalent to object->has_value,
but returns the inverse result. object->is_on
is equivalent to object->has_value: @on
and object->is_off
is equivalent to object->has_value: @off.
->is_on ->is_off \== ->not_has_value send_super(Self, initialise).
Any class should have a method object->initialise.
This method is invoked from PCE's virtual machine to initialise an
object from the parameters given to the object creation operation (new/2.
class create,
class<-instance.
The creation of objects is discussed in detail with class<-instance.
<-instance <-object).
Called when -while loading an instance from a file-, the current
definition of the class has a new instance variable (compared to when
the instance was saved to file using object->save_in_file).
The argument is the new variable
object from the class. May be used to initialise the new slot to some
sensible value.
->convert_loaded_object-changed_messages <-inspect ->freed_message ->created_message ->changed_message<-convert
converts class-names to
class objects:
send(Obj, instance_of, graphical)
is the advised way to verify that Obj is a graphical.
The method pce<-convert
may be used to combine testing with possible type conversion. See also type->validate
and type<-check.
If one wants to test whether an object is a graphical
object, a node object
or @nil, the
following two test are equivalent:
( send(Obj, instance_of, graphical) ; send(Obj, instance_of, node) ; Obj == @nil )
or
send(type('graphical|node*'), validate, Obj)
<-convert<-lock_object
<-lock_object <-_flags ->protect<-object_reference.
Diagnostics:
Bugs: Unlike with the predicate new/2, no exception is raised if the object already exists.
->rename_reference <-name_reference ->free
or one of the other objects destruction methods. The global PCE
objects @pce,
@prolog, etc.
are protected this way.
There is no way to unprotect protected objects or to destroy them.
->destroy <-protect <-_flags ->lock_object ->free ->destroy<-receiver and invokes visual->report
on this object.
If @event
is unbound the error is caused by a query from the
host-language
interaction window and PCE thus prints the message using pce->format.
Some classes redefine this method because they know they are
related to some visual
object. See also object<-report_to.
->reportObj1?class == Obj2?class.
and
message(Obj1, same_class, Obj2)
<-class ->is_a->equal
performs the same test, but is refined by various classes to test for same properties.
See -for example- point->equal.<-object. When the object is
reloaded in this PCE process, the combined functionality is similar to object<-clone.
When the data, manipulated by the application is stored in PCE, the
normal way is to attach all this information to a single object
(normally a hash_table, sheet or chain) and save this object to a file.
All attached objects (i.e. all data needed by
the application to save its persistent data) are then saved
in the file.
PCE's save and load functionality has a limited way to deal with
versions. The conversion activities are described with source_sink<-object.
Diagnostics:
.g. windows, cursors,
etc.).
Diagnostics related to opening, writing and closing a file are applicable as well.
Bugs:
->check_object <-clone <-object -save_style <-get_class
for details..
->send_method<-hypered
objects. Similar to object<-get_hyper,
but does not stop if the method is received successfully. Succeeds if
there was at least one hypered object accepting the message, fails
otherwise.|chain->send_class.
->send_class <-all_send_methods ->slot ->send_method ->get_method <-get_sub.<-get_super ->send_super
and object->send_vector,
creating an argument vector from the leading arguments and vector and
invoking behaviour defined at the super-class. See object->send_super
and object->send_vector
for details.
->send_super ->send_vector->send_vector
supports the implementation of methods with variable argument list. Its
format is:
unchecked..., Vector, [shift]
First, a list is created containing the following arguments:
unchecked...Next, the first element of this list is used as the selector and the remaining arguments as the arguments to the message. Examples:
vector(write_ln, 'Hello World')).vector('Hello World')).
Defaults: Shift defaults to 0.
Diagnostics: Fails silently if the selector cannot be created,
->forward_vector ->send_super_vector <-get_vector |int,
uncheckedThe slot specification (first argument) is either the slot-name, or the offset in the object (1-based). The latter possibility is for very specific (internal) use.
This method should only be used from a send-method that has the same
name (selector) as the slot and serves as a wrapper around
the slot to deal with side-effects:
:- pce_begin_class(person, object).
variable(date_of_birth, date, get, "When person was born").
...
date_of_birth(Person, Date:date) :->
( send(Date, after, new(date))
-> send(Person, report, error,
'Cannot be born in the future!'),
fail
; send(Person, slot, date_of_birth, Date)
).
Bugs: This message should also apply to object-level defined
attributes (see
object->attribute.
<-slot ->send_method ->send_method->unlink
is called by object->free.
Its task is to unlink the instance from its environment. The object->unlink
method may not be called directly by the user. The user should provide
an unlink method when writing a user-defined class that requires
specialised unlink behaviour.
Some examples:
<-graphicals
and update the display.
NOTE: Unlink should never be called directly by the user. Any
user-defined object->unlink
method should invoke the method of the super-class (see object->send_super).
See also object->free, object->done, visual->destroy
and object->unlinking
->free->unlink’ed.
Intended as a test in object->unlink
methods to avoid unnecessary computation.