Skip to content

How to Program in Self

Stephen De Gabrielle edited this page Jan 19, 2015 · 14 revisions

This version of 'How to Program in Self' is taken from the Self Handbook at http://handbook.selflanguage.org/4.5/howtoprg.html It references the original images, but has some small changes.

Introduction

The Self programming environment provides facilities for writing programs, and the transporter provides a way to save them as source files. Of all the parts of Self, the programming environment probably has the least research ambition in it. We simply needed to concentrate the innovation in other areas: language design, compiler technology, user interface. The Self programming environment strives to meet the high standard set by Smalltalk’s, but with a more concrete feels. The transporter, on the other hand, is somewhere in-between completely innovative research and dull development. It attempts to pull off a novel feat—programming live objects instead of text—and partially succeeds. Its novelty lies in its view of programs as collections of slots, not objects or classes, and its extraction of the programmer’s intentions from a web of live objects.

Since Self 4.0, the environment has evolved a little—mostly in the form of new affordances. On the Macintosh, Self 4.1 uses option-click for a middle-mouse click, and uses command- (the apple key) click for the right button click. So wherever the text says “left-button-click” just click with the mouse, where it says “middle-button click” hold down the option key and click with the mouse, and where it says “right button click” hold down the command key and click with the mouse. I use a Kensington Turbo Mouse with the buttons mapped appropriately. These mappings are defined in Self, so you can change them by editing the whichButton: method in the initialization category in traits ui2MacEvent.

Browsing Concepts

Introducing the Outliner

Objects in the Self 4.5 environment are represented as outliners, which can expand to show increasing levels of detail. One of these objects has been designed to provide a convenient context for typed-in commands, and so it is called the shell. If the shell is not already present on your screen, you can summon it by pressing the middle mouse button on the background and selecting shell.

shell

In Self 4.5, outliners now sport three small buttons in the top-right-hand corner labeled “/\”, “E”, and “X”. These buttons summon the object’s parents, add an evaluator text region to the bottom of the outliner, and dismiss the outliner. Press the “E” button to get an evaluator. Type anExampleObject into the evaluator (it will already be selected) and hit the Get it button (or type metareturn on UNIX, or command-return on MacOS X):

Get It

in case you are using an image that doesn't include it.

  1. save a copy of https://github.com/russellallen/self/blob/master/objects/misc/programmingExamples.self
  2. type into the shell '/download/path/here/programmingExamples.self' runScript
  3. press Do it

The result object appears in your “hand” raised above the screen as if you were dragging it with the left button. Just click the button to set it down.

anExampleObject

As with most other things on the Self screen, the left button picks it up and moves it. (For buttons and other things that use left-button for other purposes, you can grab them with marquee selection (really the carpet morph in Self) or with the “Grab” item on the right-button menu.)

Expand and Collapse

Left-click on the triangle [1] to expand the object and see more information:

anExampleObject

Now it shows a summary of modules containing the slots in this object (just programmingExamples here), four slots, and a category containing more slots, although those slots are not shown yet.

Clone this wiki locally