Smalltalk в примерах/Сообщения: различия между версиями

Содержимое удалено Содержимое добавлено
Строка 164:
What happens when a message is sent
When a message is sent to an object, the Smalltalk system looks to see if a method with that name exists for that type of object (in other words, has been written and stored in the class of the object). If there is a method, it is executed. If no method of that name is defined in the object's class, the system looks in the method dictionary for its immediate superclass. If there is no method with that name in the superclass it looks in the superclass's superclass.
The method lookup keeps working its way up the superclass hierarchy until it finds a method with that name,which it then executes. If it reaches Object and still doesn't find a method, it displays a Notifier window that gives you an opportunity go into a Debugger and figure out what went wrong 1.
Примечание:
1
What actually happens is that if a method is not found, the doesNotUnderstand: message is sent. Unless this has been overridden, the doesNotUnderstand: method tells Object
messageNotUnderstoodSignal to raise an exception. Unless you have a handle:do: block to trap this exception, the exception is unable to find a signal handler and it gets converted into another exception (an
unhandled exception exception) which invokes the EmergencyHandler. Unless you have overridden the behavior of the EmergencyHandler, it opens a Notifier window.
-->