An introduction to Clamato for Smalltalkers
- Floating at the top right is the traditional counter example. Try out the buttons.
- Bring up the Cæsar browser: . You should be looking at the
Counterclass. Select its
- Note the
-before the message pattern. This marks the current method as an instance method. Class methods have a
+(Objective-C developers will recognize this convention).
- Note that the
counterinstance variable has a
@prefix. This one’s taken from Ruby.
- Let’s extract the incrementing of
@counterinto a separate method. Replace
@counter := @counter + 1with
self incrementand hit Save.
- Select all in the code pane and add the
- increment @counter := @counter + 1.
Until you add the final period (which is required), there will be a PARSE ERROR message below the code pane. Once you’ve got it right, hit Save.
incrementshould appear in the list of methods on the left.
- Make sure that hitting + still works, then experiment with changing it to
@counter + 10, etc.
- Let’s explore the code a little bit. Go back to the
renderOn:method. The Methods menu shows all of the selectors that are sent by this method. Let’s choose
- Note that the search at the top of the browser has changed to
onClick:. This is equivalent to an implementors browser for that selector.
- You can see in the methods list above that there is only one implementor of
onClick:, which is the
JQueryclass. Click on
JQueryin the class column to see the complete JQuery protocol.
- Hit the ← button to go back to our
onClick:search. The ← and → buttons work like in a web browser.
- You can also click on the
onClick:that are just above the code pane. Clicking on
onClick:will change the search to
#onClick:, which is equivalent to a senders browser. You can see that it’s mostly sent from within the
Browserclass which implements Cæsar.
Counterto the search field so that it reads
#onClick: Counter. This filters the methods to only be those within the
Counterclass (in this case, just
- Keep playing!