Menu

Syntax

Ove Kåven

Syntax for the imperative paradigm

The basic syntax uses elements from C++, C#, Java, and Pascal. The structure is similar to C++, but variable/field/parameter declarations are somewhat inspired by Pascal syntax, where it's very clear whether something is supposed to be a type or not. This allows the compiler to parse any module without needing to parse imported modules first. Since the language doesn't use header files, this can be a good thing.

Hello, World

Here's the classic Hello World program, as it might look in MORTAL:

import "stdio"

public main(): int
{
  stdout.printf("Hello World\n")
  return 0
}

Unicode support

The compiler supports Unicode. Neither identifiers nor user-defined operators need to be ASCII. However, non-ASCII operators are restricted to the characters classified as "Math Symbol" in the Unicode character tables.

Declarations

Forward declarations are never necessary. The compiler is multipass and does not have a problem with you referring to a type, variable, or function which is defined later, even circularly.

There are no header files, modules are imported directly. (If you need to get an overview of a module's public interface, you should use other tools. For example, you could use something to generate documentation from the source code, or use an IDE that can generate an index of the source code.)

Topics


Related

Wiki: Home
Wiki: Syntax-Classes
Wiki: Syntax-Declarations
Wiki: Syntax-Expressions
Wiki: Syntax-Functions
Wiki: Syntax-Statements

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.