Skip to main content

Basics

ACPUL 1.01

ACPUL Programming Language

Key features

  • formulas
  • everything is float
  • EOL ; is required

Formula

ACPUL operates on formulas.

The formula header defines a formula

### my.formula

Multiple formulas example

### my.formula1

rnd(u0);

### my.formula2

sin(x);

Why ;?

; is important! in ACPUL 1.01

0;
a 0;
a b;
a=0;
a:=0;
a+=1;
if (a) {...};
while (a) {...};

Indent

ACPUL is designed for any screen size, so one indent is preferred.

1 indent (default)

2 indent (due to editors like VSCode)

Name

Define a name as a number, function or object.

a 1;        # a is 1 (number)

fn rnd(u0); # fn is function (expression), return a random number 0..1

fn { # the same
rnd(u0); # return a random number 0..1
};

color { # color is an object with r,g,b values
r 0;
g 0;
b 0;
};

Name will be reassigned on the next declaration.

a 0;        # a is 0  
a 1; # a is 1, no error

a rnd(u0); # a is a random function

a { # or like this
rnd(u0);
};

a { # define a.b is 1
b 1;
};

a.b; # b is 1

a { # redefine a, a.c is 2
c 2;
};

a.b; # error: name not found
a.c; # c is 2

Follow '_'

Follow _ for joining objects with the same names.

a {         # define a.b is 1
b 1;
};

a {
_; # follow previous a, join
c 2;
};

a.b; # b is 1, no error
a.c; # c is 2

A link is an association of one object to another.

a 1;
b a; # b link to a

a; # a is 1
b; # b is 1, the same

c {
d 2;
};

e c; # e is c
e.d; # e.d is 2;

Import @file

Import here

_ @sys.node;       # use sys.node

Import as object

module @my.module; # module is my.module
module.run;

Variable

The ACPUL programming language has 3 variable declaration operators.

Define a new variable. Execution independent:

a 0;        # a is 0, define a variable

Update an existing variable:

b 0;        # b is 0, define a variable
b:=1; # b is 1, update

Set a new variable:

a=1;        # set a new variable 

# a=1 is the same as
a 0;
a:=1;

Operator if

if (expr) {
...
};

Note:

There is no else operator in ACPUL 1.01.

Operator while

while (expr) {
...
};
i = 0;
while (i < 5) {
i+=1;
};

Note:

Infinite loops will be broken automatically.

Reliability

No recursion

No recursive calls.

Maximum call depth: 256 for file import.

No infinite loops

Infinite loops will be broken automatically.

No memory overflow

Malicious formulas will be terminated automatically.