That Other Use for Squeak

Paul Fernhout pdfernhout at kurtz-fernhout.com
Sun Jul 2 21:30:17 UTC 2000


Mark Guzdial wrote:
> The part I completely agree with Andy on is that common programming
> languages are nowhere easy enough to learn yet, and I hope that the
> right notation does lead to common-daily-use.  

I've been thinking myself along the lines of using Python's
indentational block structuring with Smalltalk's keywords, and a minimal
of punctuation to create an easy reading notation.

So in "PaulTalk" :-) notation, for example, if I understood your
requirements correctly:

define MyClass>>averagePositiveIntegers: aCollection until: flag
    "average positive integers in a collection 
    up to  but not including a flag"
    |sum numPositiveValues average|
    sum := 0
    numPositiveValues := 0
    for value in aCollection
        if value == flag
            break
        elif value > 0
            sum := sum + value
            numPositiveValues := numPositiveValues + 1
    if numPositiveValues == 0
       Dialog show: 'There were no positive values' type: #Alert
       ^0
    average := sum / numPositiveValue
    ^average
            
Note the absense of periods which are not needed when there is one
statement per line. Periods could of course be used optionally to
seperate statements on one line.

You mention ease of learning. What I want personally more than anything
is transparency of the system as much as possible from the high level
language down to the VM and the machine code it runs. This is for
political and philosophical reasons. 

The thing that is nice about avoiding them or limiting them to the
PocketSmalltalk sense (great job guys!) is that I could easily put this
sort of system on top of a Forth based VM with a conventional stack.

Here is a VM call example which compiles easily right into something
like Forth.

define Integer>>timesInteger: otherInteger
  "assumes double dispatching so arguments are correct types"
  VM push4: self byteArray.
  VM convertSmalltalkIntegerToNativeInteger.
  VM push4: otherInteger byteArray.
  VM convertSmalltalkIntegerToNativeInteger.
  VM integerMultiply.
  VM convertNativeIntegerValueToSmalltalkInteger.
  ^VM pop

Polymorphic methods (the normal case) might translate to sequences like:
define Object>>send: receiver message: selector
    VM push: receiver.
    VM push: selector.
    VM polymorphicDispatch.

Also if you declare certain methods as non-polymorphic, perhaps making
assumptions about argument types, you can flatten entire trees of
"PaulTalk" method calls into a single Forth word. For numerical
computations (an interest of mine for educational simulations) this
might be a big win.

(Actually, since this language is a hybrid of Python and Smalltalk, it
might best be called "Pytalk" or "Smallthon".).

This approach might be more easily maintainable and relatively portable,
even if it is slower than an highly optimized VM system produced using a
C compiler. In the system I outlined, I could trace the correspondance
of every statement down to the machine code it runs. 

-Paul Fernhout
Kurtz-Fernhout Software 
=========================================================
Developers of custom software and educational simulations
Creators of the Garden with Insight(TM) garden simulator
http://www.kurtz-fernhout.com





More information about the Squeak-dev mailing list