objective.st
Home
About
Language
Examples
Scripting
URIs
Outlook
Publications
Download
Blog

Language

Literals

Numbers: 1, 2, 3, 3.0

Strings: 'Hello World'

Interpolated Strings: "Hello {name}"

Arrays: #( 1,2,3,4 )

Dictionaries: `#{ #key : 'value' }

Objects: #Class{ #ivar : 'value' }

Identifiers

See URIs.

Messages

Like Smalltalk, virtually all of the basics of expressions are handlde by message conneectors, and again like Smalltalk, Objective-S distinguishes three kinds of messaege: unary, binary, keyword.

Unary:

receiver message.

Binary:

2 * 3.

Keyword:

'Hello ' stringByAppendingString:'World!'.

The statement separator is the period '.'.

Objective-S has two mechanisms for chaining muliple messages. The cascade, denoted by a semicolon, sends multiple messages to the same receiver:

receiver msg1;
         msg2;
         msg3.

The pipe '|' evaluates the expression on its right wiith the result of the message on its left. This makes messaging consistent with pipelines and also avoids the need for brackets in many cases.

 a + b | negated.
 'hello' stringByAppendingString:' world!'  | captalizedString.

Assignment

The assignment connector uses the left arrow '←', but also accepts the Smalltalk/Pascal convention of ':='.

a := 2.
b ← 3.

Blocks and Control Structures

Blocks in Objective-S use curly brackets.

 { 3+4 }.

Block parameters are separated from the body by the pipe symbol ('|') like in Smalltalk and start with colons:

 { :a :b | a+b }.

As is the case in Smalltalk, control structures are implemented using blocks and plain message sends, for example conditionals, which can be used as expressions.

 flag ifTrue: { a:=2 } ifFalse:{ a:=3 }.
 a := flag ifTrue: { 2. } ifFalse:{ 3 }.

Classes

Classes are components that correspond to the class construct from other object-oriented languages.

class Hello : NSObject {
    var someVar.
}

Superclass can be omitted. Each kind of component has its own default superclass, in the cases of classes that superclass is NSObject.

class Hello {
    var someVar.
}

Methods

Method components are defined using a syntax that is closely modeled on Objetive-C, with thee minus sign '-' introducing an instance method definition. The method body is enclosed in curly braces. There is no need for a return statement, no return type given means an object is returned.

class Hello {
   -greet {
        'Hello World!'.
   }
}

Parameters

class Hello {
   -greet:name {
        "Hello {name}!".
   }
}

Types are enclosed in angle brackets:

class DeepThought {
   -<int>answer {
        6*7.
   }
}

Protocols

Similar to the way that classes are components that group method components, protocols are compound connectors that group message connectors.

protocol ModelDidChange  { 
      -<void>modelDidChange:ref.
}

Filters

TBD.

Schemes (Stores)

TBD.

Copyright (c) 2012-2020 Marcel Weiher (st)