Statements: signal

The signal statement sends a signal to a slot method.


Form 1:


Form 2:



The signal statement causes an immediate invocation of a slot method determined by the slot-expression. The calling method waits until the slot method has completed its execution. In Chora, signals and slots provide a technique where one object can notify second object without knowing the identity of this object. If the slot-expression results in the value null, then nothing occurs and the signal statement is finished. For example:

var slot s1 = someObject.onShowMenu;
var slot s2 = null;

// Execute the slot method 'onShowMenu' of 'someObject'
signal s1;

// The expressions results in 'null'. Nothing happens.
signal s2;

Per default, when a signal is sent, the identity of the sender object (see this variable) is passed on to the slot method in the hidden parameter sender. Thereupon the implementation of the slot method can evaluate or even interact with the sending object. In its second form, the signal statement allows you to explicitly specify in the sender-expression another object to be passed on instead of the actual sender object, even a null object. It permits the sender to feign a foreign identity against the slot method. For example, you can implement a button able to send signals with the identity of its superior component:

var slot theSlot = ...;

// Send the signal with the identity of the superior GUI component.
signal theSlot, Owner;

Please note, slot methods can be invoked also by using the postsignal and the idlesignal statements.