29.11.2014 Views

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This dialog box indicates that New is not understood by the class Set (note the terminology). This is<br />

<strong>an</strong> example of how <strong>Smalltalk</strong> (<strong><strong>an</strong>d</strong> VisualWorks in particular) attempts to help you if it finds a message<br />

it does not underst<strong><strong>an</strong>d</strong>. In this case it did not underst<strong><strong>an</strong>d</strong> “New”. It identified this as a problem <strong><strong>an</strong>d</strong> is<br />

now allowing you (the user) to<br />

• Abort <strong><strong>an</strong>d</strong> correct the error yourself,<br />

• Proceed as though nothing had gone wrong (however it would probably fail in <strong>an</strong>other way<br />

immediately) or to<br />

• Correct it, the error, with the system’s help.<br />

The correction option is illustrated below. Click on the “correct it” option. You will then see the<br />

following selection box:<br />

Select “OK”.<br />

This is <strong>an</strong> example of how <strong>Smalltalk</strong> attempts to help you if it finds a m essage it does not<br />

underst<strong><strong>an</strong>d</strong>. In this case it did not underst<strong><strong>an</strong>d</strong> “New”, but it found that Sets do underst<strong><strong>an</strong>d</strong> “new”. As<br />

“new” is very similar to “New”, <strong>Smalltalk</strong> presented it as a possible alternative.<br />

Once you have selected “OK” on the selection dialog, you should then see the following dialog.<br />

For the moment select “proceed”. The problem here is not actually with item, but is a feature of<br />

<strong>an</strong>other problem which we will come back to later. Once you have selected “proceed” you will then see:<br />

This dialog was generated because, Peter, does not have single quotes around it (single quotes are<br />

used to indicate a string). The system therefore assumes that it is a variable which has yet to be defined.<br />

At this point press “c<strong>an</strong>cel”. You should find that Peter is h ighlighted in the Workspace. This<br />

illustrates how VisualWorks attempts to point out where the problem is. Now place single quotes<br />

around Peter, e.g.<br />

temp add: 'Peter'.<br />

Next re-select the whole lot <strong><strong>an</strong>d</strong> “do it” again. You will again see a dialog warning yo u that item<br />

isn’t defined. For the moment select proceed.<br />

You will now get <strong>an</strong> Exception raised. This is because the Tr<strong>an</strong>script object does not underst<strong><strong>an</strong>d</strong> the<br />

message “show”. The dialog you see should look like this:<br />

58

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!