... Squeak, the Smalltalk of the
Each instance variable (more or less like object properties)
should have its access method (one to assign a value to it, and one
to read the value from that instance variable).
Squeak has a preference that allows automatic generation, when
required, of the access methods.
From the menu World - appearance - preferences - type (in the
textbox with red colored font) autoacc, and press Enter. Then,
select the Autoaccessors characteristic.
After doing this, Squeak will ask to create each required accesor,
the first time an object needs to be read or saved in an instance
Obviously, Squeak creates accessors in a generic way; if the
programmer needs more specialized code, he should overwrite the code
generated by Squeak.
The accessors created, for instance, for url, are:
This is the read accessor, ^ is the symbol that indicates that it
should return the object whose name follows, in this case, url.
url := anObject
In the first line, the colon means that it receives another
object (in this case, anObject) as a parameter, in the second, := is
the assignation symbol, which means that url is assigned anObject,
therefore, url = anObject. Sometimes, instead of :=, <- is used.
Some modified accessors:
parsedPage := HtmlParser parse: anObject
The last statement means that parsedPage obtains its value as the
result of the expression to the right of the :=, that is, HtmlParser
The method parse: of HtmlParser receives anObject (the object
which we want to parse), then, the content of parsedPage is the
result of applying the parse: method of the HtmlParser object to the
object which we pass (in this case, the Web page).
HtmlParser is an object that also lives in the Squeak image.
Opening the image is like opening the old trunk of our grandmother,
which is full of strange and interesting things. Thus, within a
Squeak image, we find the compiler, the debugger, an Internet
browser, an e-mail client, scripting, tools to work with 3D objects,
objects for connectivity and networking, etc. ... thousands of
things, ready to be used.
urlPage := HTTPSocket httpGetDocument: anObject
Here, the HTTPSocket httpGetDocument: anObject obtains the object
anObject from the Web, and assigns it to a urlpage.
HTTPSocket, too, is an object that lives in the Squeak image. All
objects that live in the image can obviously be modified or used to
create subclasses of themselves (inheritance).
Try to write the methods in the lower half of the browser and
accept them, as shown here: