Umstieg zu JM° / Für Programmierer


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
# Zeilen-Kommentar
Block
/* Block
Kommentar */
All following
#**#

Variables

Variables
abcDef = 12 + 34
Constants
GHI_JKL = "foo"

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
If( a > 3)
"Bigger".print
.else
"Smaller".print
( a > 3)
"Bigger".print
.else
"Smaller".print
Count loop
Count( 3, 9 )
it.print
{ 3, 9 }.print
For loop
For( i=3, i<9, i=++)
it.print
3.for( each < 9, each++)
it.print
While loop
i = 5
While( i < 9 )
i += 2
5.while( each < 9 )
it += 2
Repeat loop
i = 5
Repeat( i < 9 )
i += 2
5.repeat( each < 9 )
it += 2

Output

Description Classic Alternatively
Without line break
Echo( 2+3 )
(2+3).echo
With line break
Print( 2+3 )
(2+3).print

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


- Powered by OghsWiki -

 

 

Sponsor

The development of "JayMo" is currently only possible through personal initiative.

Received:  0 €