34 " |
36 " |
35 ! |
37 ! |
36 |
38 |
37 documentation |
39 documentation |
38 " |
40 " |
39 Instances of Message represent a message being sent. |
41 Instances of Message represent a message being sent, consisting of |
|
42 the message selector and the message arguments. |
|
43 |
40 During normal execution, message objects are NEVER used - |
44 During normal execution, message objects are NEVER used - |
41 instead, argument passing is done more performant via the stack |
45 instead, argument passing is done more performant via the stack |
42 or in registers (depends on how your C compiler passes arguments). |
46 or in registers (depends on how your C compiler passes arguments). |
43 |
47 |
44 However, messageObjects ARE created, when a message send fails |
48 However, messageObjects ARE created, when a message send fails |
45 (i.e. some message is not understood). |
49 (i.e. some message is not understood). |
46 In this case, the selector and arguments of the failing messare |
50 In this case, the selector and arguments of the failing message |
47 are squashed into a new instance of Message, and a #doesNotUnderstand: |
51 are squashed into a new instance of Message, and a #doesNotUnderstand: |
48 message is sent to the original receiver, passing the message object |
52 message is sent to the original receiver, passing the message object |
49 as argument. |
53 as argument. |
50 |
54 |
51 Typically, #doesNotUnderstand: is not redefined in the receivers class, |
55 Typically, #doesNotUnderstand: is not redefined in the receiver's class, |
52 therefore Object>>doesNotUnderstand: gets evaluated. |
56 so the lookup finds Object>>doesNotUnderstand: and this is evaluated. |
53 There, a debugger is opened and the thread is suspended. |
57 There, a debugger is opened on the suspended thread (actually, it is a little |
54 However, it is possible to redefine this method, which |
58 more complicated: actually a MessageNotUnderstood exception is raised there, |
55 allows for re-evaluation of the failed send (after some cleanup), |
59 which - if not handled by an exception handler - opens the debugger). |
56 to upload some code or to simply ignore the error. |
60 |
|
61 However, it is possible and common to redefine the doesNotUnderstand method, |
|
62 which allows for re-evaluation of the failed send (after some cleanup), |
|
63 to upload some code, to forward the message to another destination, |
|
64 or to simply ignore the error. |
57 |
65 |
58 As an example of its use, see the implementation of the Autoload-class, |
66 As an example of its use, see the implementation of the Autoload-class, |
59 or how ScrollableView forwards unknown messages to its slave-view. |
67 or how ScrollableView forwards unknown messages to its slave-view. |
60 |
68 |
61 Elegance hint: actually, Object>>doesNotUnderstand: raises an exception |
69 Elegance hint: as mentioned above, Object>>doesNotUnderstand: actually |
62 which can be handled - in most situations, providing an exception handler |
70 raises an exception which can be handled. In many situations, providing |
63 instead of redefining #doesNotUnderstand is the better way to do things. |
71 an exception handler instead of redefining #doesNotUnderstand is the |
|
72 better way to do things. |
64 |
73 |
65 |
74 |
66 Notice: |
75 Notice: |
67 Since the layout of Message-objects is known by the runtime system |
76 The layout of Message-objects is known by the runtime system (VM) |
68 (it has to create those objects in case of a failure) |
77 (it has to create those objects in case of a failure) |
69 it is not allowed to change the definition of this class. |
78 so it is not allowed to change the definition of this class. |
70 |
79 |
71 [See also:] |
80 [See also:] |
72 Signal Exception MessageSend |
81 Signal Exception MessageSend |
73 |
82 |
74 [author:] |
83 [author:] |