| Did you know ... | Search Documentation: |
| Get methods |
get(Obj, ?(Obj?class?term_names, element, N), Arg).
This behaviour is intended to remain reserved for system usage. Do not rely on its definition.
<-_arg <-functor <-_arity -term_names <-_arity <-functor <-_arg |int -> unchecked?- new(O, @display?size), get(O, '_class_name', C1), get(O, class_name, C2). C1 = ? C2 = size
Bugs: It is probably more elegant to introduce a separate send- and get- operation that does not evaluate the receiver.
<-class create equals @on,
this call will always succeed, possibly returning an empty chain.
Otherwise the call might fail.
The following extensions are defined:
object ->attributeObject-level instance variable constraintBinary constraint between two objects hyperBinary relation (two-way attribute) object ->recogniserHandler for event objects (class graphical) object ->send_methodObject-level method (send) object ->get_methodObject-level method (get)
See also class constraint and class hyper.
->attribute ->attribute.
The attribute may also me requested using a plain get operation:
?- new(@o, object), send(@o, attribute, gnus, 4). ?- get(@o, attribute, gnus, G). ?- get(@o, gnus, G).
The two are equivalent, except that the latter gives an error if no such attribute is defined.
->instance_of
or object<-class_name.
In most situations the first is to be preferred.
<-class_name <-_class ->same_classget(Object?class, name, ClassName).
<-class <-_class_name<-Name
is equivalent.<-clone
creates a clone of an object. The semantics of cloning objects in
general are difficult to define. Which related objects are to be cloned
and which are to be shared between the clone and the original object?
The approach taken by PCE is not particularly neat. We do not recommend heavy use of this facility.
Object are cloned recursively. This implies all objects
that can be reached from this object are cloned as well. The algorithm
deals correctly with cyclic structures.
While executing a recursive clone, two flags may influence the result:
variable <-clone_styleDefines the type of relation class <-clone_styleDefines the type of object
Please consult the documentation of these for details.
Bugs: The semantics are ill defined. Be very carefull
with plain cloning and study this description carefully
before going ahead. When in doubt, use the inspector tool
from the main menu to find out about the result.
-clone_style ->save_in_file|char_array -> object<-convert
is called by type<-translate,
part of the generic type-checking and type conversion system. It is not
a normal method not the receiver, but the result is an
instance of the class on which the method is defined. The receiver is
normally the class.
The task of the object<-convert
method is to translate the argument into an instance of the requested
type.
For class object
itself no translation is necessary as anything in PCE already is an
instance of class object.
This method will therefore never be called directly by the PCE type
conversion system. This method translates a text (char_array
object) of the form @<name> into an object if <name>
is a valid object reference. This method is useful for defining other
conversion functions.
->initialise,
scan the goal stack searching for a receiver higher in the goal stack
for which condition succeeds. Condition is executed with the following
arguments:
@receiver receiving object @arg1 receiver of message of parent goal @arg2 implementation of message of parent goal
This method is intended to find the context in which an object (often
a graphical) is created, allowing it to query the context for additional
information. See also visual<-contained_in.
hyper_name is the
name of the hyper, seen from the receiver of this message. If hyper_name
is @default,
all hypers are considered. test is a code
object. If it is not @default,
it is executed using the following arguments:
@arg1 Receiver of this message @arg2 Hyper object @arg3 Object at other end of the hyper.
See also object<-hypered.
<-class_name.
<-_arity <-_arg->get_method.
This method serves a similar purpose as object->get_super
when using class-level programming.
->get_methodbroadcast get operation on objects object<-hypered
to this object. If a hyper_name is given only hypers with this name are
considered. Otherwise all hypers are considered. As soon as one of the
hypered objects returns a value, this method returns with this value.
Otherwise the method fails. Example:
?- new(@o, object),
new(_, hyper(@o, bitmap('pce.bm'), bitmap)),
new(_, hyper(@o, text(hello), text)).
?- pce_catch_error(no_behaviour,
get(@o, get_hyper,
@default, string, S).
S = hello
?- pce_catch_error(no_behaviour,
get(@o, get_hyper,
@default, pixel, 3, 5, P).
P = @off
The first query is answered by the text
object, while the latter is answered by the bitmap
object (delegated to the bitmap<-image).
Note the use of pce_catch_error/2 to avoid
an error while broadcasting to objects that do not understand the
method.
->attribute).<-send_method<-delegate
The tuple<-first contains the receiver,
which is either the object itself or the object the message will be
delegated to. The
tuple<-second contains the behaviour
object that implements the method.
Examples:
?- new(@p, point), get(@p, send_method, mirror, tuple(Object, Impl)). Object = @p/point Impl = @632241/send_method ?- new(@v, view), get(@v, send_method, append, tuple(Object, Impl)). Object = @833889/editor Impl = @749374/send_method
The second example indicates that, when a message object->append
is sent to
@v it will be delegated to the editor @833889.
See also object->has_get_method, object->has_send_method
and object<-all_send_methods.
->get_method
for further details.
Bugs: Actually, a normal get operation executed in a method
already performs a
object<-get_sub.
Reserved fro future extension.
.e. object<-get_super
is always to it self).
See also object<-slot.
->send_super.g.
get(@prolog, get_vector, vector(plus, 1, 1), X).
Is a very complicated way to add 1 and 1.
This behaviour is intended to deal with delegating messages trapped
via the object->get_catch_all behaviour.
->send_vector
@arg1 This object @arg2 The hyper object @arg3 The object at the other end of the hyper
The first matching object is returned. See also object<-all_hypers.
->inspect
->inspect <-_inspect
A locked object is destroyed by object->free.
To protect an object against
object->free,
use object->protect.
When @off,
the lock is removed from the object. If the object has no references, it
will be object->free’d.
If this is not desirable, use object<-unlock.
->protect ->done ->lock_object|int->name_reference)
or integer reference for objects that have no named reference. See also
pce<-object_from_reference.
<-object_from_reference<-print_name
is intended to convert an object into a textual representation. It
serves two purposes:
->format<-print_name_of_value.
This method is redefined by various subclasses. object<-print_name
itself performs the following steps:<-name and
the return value can be converted into a char_array
object, return this converted value.->protect
->protectNote that PCE does not know which objects have references to an object; slot-relations are uni-directional.
<-_references->report.
The default for non-visual
objects is the receiver of the current event (@event).
See also
visual<-report_to.|int -> unchecked
This method is used in the implementation of get_method
objects if the get method wants to access a slot with the same name
without interaction from the method. See also class->get_method.
->get_method ->get_method ->slot <-_slot->save_in_file
to handle shared object resources (colours, fonts, etc.). If this method
is executed successfully, object->save_in_file
stores the classname of the the object and the returned object.
source_sink<-object loads the
classname, converts the classname to a type
object, loads the returned reference object and attempts type<-check
to produce an object of the requested type.
See colour<-storage_reference
for an example.
<-self.
If, after unlocking, the object has no references, it will be pushed on
the‘anser stack’, making it visible to the incremental
garbage collector.
In combination with object->lock_object,
this method may be used to disconnect an object from its environment,
handing it back to the incremental garbage collector. An example can be
found in emacs_window<-prompt, a part of
PceEmacs.
Assume we have a chain
object holding a point and we want to delete the object from the chain
without deleting the point. Direct usage of chain->delete
may destroy the point. The following code avoids this:
send(Point, lock_object, @on), send(Chain, delete, Point), get(Point, unlock, _).