links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Message passing in Smalltalk compared to Java
Last updated at 2:33 am UTC on 10 May 2018
Smalltalk code may look unreadable to a reader more used to a mainstream language such as Java or C#. The main stumbling block is the syntax for message passing.

The mainstream syntax is

    receiver.selector (arg1, arg2, ...)
    e.g., fileDirectory.copy (file1, file2);

The Smalltalk (and Squeak) syntax is different

    receiver arg1Name: arg1 arg2Name: arg2.
    e.g., fileDirectory copyFrom: file1 to: file2.

Internally, the Squeak compiler immediately transforms the above syntax to the mainstream form:

    receiver arg1name:arg2Name (arg1, arg2).
    E.g., fileDirectory copyFrom:to: (file1, file2)

This works because the colon (:) is a legal character in a message selector. It follows that the number of colons in a selector equals the number of arguments.

Source: http://folk.uio.no/trygver/2011/SqueakExamples/index.html

See keyword message