Für Programmierer
This page is for all readers with programming experience and should give a quick overview of the language.
It is important to understand that in JM° there are only objects with functions and events. Supposed "keywords" like "If" or "For" are therefore also "only" objects with special capabilities (control objects).
JM° is written very lean, so curly braces for blocks and a line terminating semicolon are omitted.
Important atomic types
| Type | Type | Schreibweise |
|---|---|---|
| True values | Bool | true, false |
| Integers | Int | 123 |
| Decimal numbers | Dec | 123.456 |
| Character | Char | 'a' |
| Text | Str | "Foo" |
| Nothing | Nil | nil |
Comments
| Type | Schreibweise |
|---|---|
| Line |
|
| Block |
|
| All following |
|
Variables
| Variables |
|
| Constants |
|
Create object
A new object is created, in which the type is written out
Random
An object is thus the instance of a type.
Functions
| Mathematical | Append without dot | Different priorities | 5+5 |
| Alphanumeric | Append with dot | Always highest priority | 5.print |
Commands & Command Chains
A command consists of an object and a function. An object is always needed first as a starting base.
Further functions can be appended.
1.echo.echo.echo.print
Brackets can be used to group commands.
(( 2 + 3 ) * 4 ).print
Several commands in one line are separated with a semicolon:
3.print; 9.print
Important control objects
Beside the classical notation with keywords (-objects), further alternative notations exist in JM°.
Blocks are indented with tabs, but not marked further.
| Description | Classic | Alternatively |
|---|---|---|
| If then else |
"Bigger".print.else "Smaller".print |
"Bigger".print.else "Smaller".print |
| Count loop |
it.print |
|
| For loop |
it.print |
it.print |
| While loop |
While( i < 9 )i += 2 |
it += 2 |
| Repeat loop |
Repeat( i < 9 )i += 2 |
it += 2 |
Output
| Description | Classic | Alternatively |
|---|---|---|
| Without line break |
|
|
| With line break |
|
|
Own functions
Definitions are introduced with two colons.
Type specifications are optional, but can also be enforced.
Definition without parameters:
::myFunc
123.print
Definition single-line with parameters:
::mySum( a, b ) = a + b
Definition with types, default values and variable argument count
::myTest( Int a = 12, Int b = 34, Char c... )
Str s = ""+ (a+b)
c.each
s += it
func = s
Call
this.myFunc
this.mySum( 123, 345 )
this.myTest
this.myTest(56)
this.myTest(56, 78)
this.myTest(56, 78, 'h', 'e', 'l', 'l', 'o')
Own types
Types form the "blueprint" from which instances (objects) can be derived later.
The definition of parameters is identical to that of functions.
Definition:
::MyType(Bool b)
::show
b.print
Create and call function:
MyType( true ).show