Beginner smalltalk question: Open Classes and Smalltalk

Yoshiki Ohshima yoshiki at
Mon Jan 16 08:30:29 UTC 2006


  Sounds like a topic from Matz blog^^;

  Note that all classes are born with zero method, and methods are
added later; "the concept of Open Class" is not something Smalltalk
"supports", but it is what everything is built on.

  I guess you already know how to add a method from a System Browser.
If you type some code in the code pane and choose "accept" from the
menu, it is compiled and added to the selected class.

  What you can do here is to bring up the right-click menu in the code
pane, and "inspect" the "accept" menu item via Alt-click on the menu
item.  (See the attachment browser.png).

  In the inspector, you can type a expression like:

target perform: #accept orSendTo: (arguments at: 2)

(See another attchment inspector.png)

and choose "debug it" from the menu of the inspector.  This expression
is what is evaluated when you choose the menu item, and the debugger
will show up to do the step execution of the expression.  You can step
through what the Browser does when you hit the menu item.

  Along the line, you'll hit one of a method of ClassDescription
called #compile:blahblah.  As Colin wrote, what happens is is
equivalent of evaluating:

Object compile: 'one ^ 1'.

  By the way, there is a great Squeak book by Umezawa-san written in
Japanese.  It covers from "3+4" to the module system (Monticello) and
everything in 594 pages.  Arguably, it is the most through reference
on Squeak.

-- Yoshiki

At Sun, 15 Jan 2006 21:17:50 -0500,
Rich wrote:
> The Ruby language supports the concept of "Open Classs" or that at
> run-time a class can have methods added to it, or in general have it's
> definition modified.  As I understand it, the idea for this originally
> came from Smalltalk.  If so, how would I go about adding methods (in
> the workspace, for example, just to test things out)?  Thanks alot.
> -Rich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: browser.png
Type: image/png
Size: 21202 bytes
Desc: not available
Url :
-------------- next part --------------
A non-text attachment was scrubbed...
Name: inspector.png
Type: image/png
Size: 8086 bytes
Desc: not available
Url :

More information about the Squeak-dev mailing list