Linked by Thom Holwerda on Sun 4th Sep 2005 17:00 UTC, submitted by <a href=
OpenStep, GNUstep Objective Modula-2 (or ObjM2) is an extension to Modula-2 which follows the Objective-C object model and retains the bracketed Smalltalk message passing syntax introduced in Objective-C. Like Objective-C, Objective Modula-2 is a reflective, object oriented programming language with both static and dynamic typing. It is intended as a safer alternative to Objective-C for Cocoa and GNUstep software development.
Permalink for comment 27385
To read all comments associated with this story, please click here.
Message me this
by japail on Sun 4th Sep 2005 20:56 UTC
japail
Member since:
2005-06-30

Smalltalk doesn't have "bracketed message passing syntax." The brackets in Smalltalk are used for constructing blocks, which are similar to closures. Objective-C doesn't really share much with Smalltalk in terms of syntax.

How to send a parameterless message:

someObject msg.


How to send a message with one parameter:

someObject msg: argument.


How to send a message with multiple parameters:

someObject msg: argument msg2: argument2.


How to send two parameterless messages to the same object ("cascading"):

someObject msg; msg2.


Send msg to someObject and then send msg2 to the resulting object:

someObject msg msg2.


Compare whether x is larger than y, and if it is then send msg to someObject:

(x > y) ifTrue: [ someObject msg ].

Notice that [ someObject msg ] is an object (a block) passed as a parameter in the message ifTrue sent to the boolean returned by the binary message >.


1 to: 10 do: [ :n | someObject msg: n ].

Count from 1 to 10, sending each number as a parameter to msg being sent to someObject. Notice how the block has been created to expect a parameter when it's invoked.

If you're familiar with Objective-C, you'll notice how different this is from how you program with Objective-C. Smalltalk is a fairly elegant, simple language.

Reply Score: 1