Object Creation

The only way to create a new object is to inherit another one.

The object creation syntax is one of:

  • constructor expression,
  • phrase, or
  • constant.

Constructor Expression

This expression allows to derive objects and provide definitions for the result.

The syntax is:

<prefix> '(' <definitions> ')'

where

  • <prefix> is one of:
    • arbitrary expression, resulting to constructing object’s ancestor, or
    • type arguments;
  • <definitions> is a set of sentences, forming constructing object’s definition.

Note that <prefix> itself can not be a constructor expression or phrase, unless enclosed into parentheses, because otherwise the whole construct would be a single phrase.

Some examples:

void (     ~~ Inherit the core object `void`.
  Foo := 1 ~~ Declare the new field `foo`.
)
integer ( ~~ Inherit the core object `integer`.
  = 1     ~~ Define it's value.
)
foo (           ~~ Inherit some object `foo`.
  = "new value" ~~ Override it's value.
  Bar = 3       ~~ Override the field `bar`. 
)

Phrase

Any phrase can be reduced to canonical form, which is a constructor expression. So, the following:

Use object 'main' from 'console' as 'run'

is the same as

Use object (         ~~ Inherit object `use object`
  Object = "main"    ~~ Override field `object`.
  Module = "console" ~~ Override field `console`.
  Alias = "run"      ~~ Override field `alias`.
)

Constant

A constant expression creates an object inherited from some predefined one, and defines it’s value.

So, the following:

123

means roughly the same as

Integer (= 123)

While the string expression

"foo"

means roughly the same as

String (= "foo")