Clause Content

Clause content is a statement. Almost any statement can be clause content, but there are some limitations though:

  • a new field declaration can not be used as clause content;
  • an expression should be in canonical form, i.e. arbitrary phrase is not supported, only constructor expression allowed.

Phrase Object

Each phrase builds an object. This object is called phrase object.

Phrase Object Construction

A phrase constructs an object depending on the first phrase part:

  • when it is a declarative block, the phrase object is inherited from phrase prefix;
  • when it corresponds to a clause, which content is an expression, the phrase object inherits this expression;
  • otherwise, the phrase object is inherited from phrase prefix.

Some examples:

Phrase :=> void (
  Foo := 1
  <[]> Foo = *
  <''> String ()
)

Phrase () [2] ~~ Constructs an object inherited from `phrase`.
~~ Canonical form:
Phrase (
  Foo = * (= 2)
)

Phrase () 'value' ~~ Constructs an object inherited from `phrase`.
~~ Canonical form:
Phrase (
  String (= "value")
)

Phrase 'value' ~~ Constructs a string, as corresponding clause's content is an expression.
~~ Canonical form:
String (= "value")

Phrase [2] ~~ Constructs an object inherited from `phrase`.
~~ Canonical form:
Phrase (
  Foo = * (= 2)
)

Phrase Object Definition

A phrase part complements the phrase object’s definition by reproducing the corresponding clause’s content in the scope of this definition and placing the value of this part at the end:

Examples:

Phrase :=> string (
  <[]>
  <''>
  <{}>
)

~~ The following builds the same definitions:
Phrase ["value"]
Phrase 'value'
Phrase (= "value")

~~ The following:
Phrase {= "value"}
~~ Canonical form:
Phrase ({= "value"})

Field Overrider

When the clause content is a field override declaration, the clause content reproduced as a field override of the constructing object:

Phrase :=> void (
  Foo :=< integer
  <[]> Foo = * ~~ The value will be substituted from phrase part.
)

Phrase [42] ~~ The same as:
Phrase (
  Foo = * (= 42)
)

A short syntax can also be used:

Phrase :=> void (
  <[]> *Value ~~ A short form of the above.
)

Phrase [42]    ~~ The same as:
Phrase (
  *Foo (= 42)  ~~ Note that this is just a short form of field override syntax.
)

Expression

When the clause content is an arbitrary expression, this expression is reproduced in the object’s definition:

Phrase := void (
  <''> String
)

Phrase 'value' ~~ The same as:
Phrase (String (= "value"))

Blocks

When the clause content is either imperative or declarative block, the block is reproduced in object’s definition:

Phrase :=> string (
  <''> (Foo ())
)

Phrase 'value' ~~ The same as:
Phrase (
  (Foo (). = "value")
)
Phrase :=> string (
  <''> {Print "Hello"}
)

Phrase 'value' ~~ The same as:
Phrase (
  {Print "Hello". = "value"}
)

Empty Content

When the clause content is absent, the value is substituted unchanged.

This creates a condition rather than a return statement when substituted inside a block:

Phrase :=> void (
  On :=< void
  <*> On = * (
    <[]>
    = Void
  )
)

Phrase [false]
~~ Canonical form of the above:
Phrase (
  On = * (
    False  ~~ Substituted value.
    = Void ~~ Value from implicit content.
  )
)

The top-level clause with empty content does not construct anything. It just returns a value:

Phrase :=> float (
  <[]>
)

Phrase "Hello" ~~ Returns `"Hello"` unchanged, despite the type of `phrase` object is `float`.
Phrase [42]    ~~ Returns `42`. Has no connection to `phrase` object.

Phrase Prefix

A phrase prefix can be used as a field definition or as an expression. For that a $Prefix reference can be used in the appropriate clause content.