Mapping Silverlight Classes to Smalltalk

December 16, 2010

There are two basic types of objects in Silver Smalltalk.

First, there are Smalltalk objects which are created from Smalltalk classes. For example, “MyClass new” would create a new instance of the class MyClass.

Second, there are the native Silverlight objects which are written in a .Net language such as C#.

There is also a third type of object which is a hybrid of the two basic types: the “mapped” object.

A mapped object has the underlying behavior of a native Silverlight object but you can add Smalltalk methods, instance variables, and class variables to it.

An example is the “UserWindow” class which “maps” the underlying “UserWindow” type in Silverlight. You can use the ClassBrowser to browse the hierarchy of classes:


All the window classes (WorkspaceWindow, TranscriptWindow, etc) are derived from “Window”.

It is very useful to be able to map native classes this way. One advantage is speed – in the case of “UserWindow” there is a lot of handling of mouse movements which is best done in compiled C#. And another advantage is that you can libraries that were created in any of the .Net languages like C# or VB.Net.

And because the mapped classes now have Smalltalk attributes as well, you can add methods, instance variables and class variables to them. In the classes derived from “Window”, I have added instance variables for “leftPane”, “rightPanel”, “topPanel”, “bottomPanel”, etc.

In summary, “mapped” classes give you all the speed of C# and the ability to use any C# or VB.Net library. But they behave like Smalltalk classes as well, so they can be customized and extended.

The best of both worlds.


3 Responses to “Mapping Silverlight Classes to Smalltalk”

  1. Chip Nowacek Says:

    This running documentation is helpful.

  2. Chip Nowacek Says:

    Could you give an example of a native Silverlight object accessible from within the image (paragraph #3 above) or does the mapping make them accessible? Should I use .Net docs to understand these native and/or mapped objects?

    • Peter Fisk Says:

      Mapping makes all publicly accessible methods and properties of loaded assemblies available.
      In the desktop version, I restrict it somewhat for performance reasons.

      Yes, use the .Net docs for Silverlight.

      Let me know if you have trouble with any particular method.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: