Skip to content

Syntax and features

Adharsh Kamath edited this page Nov 9, 2020 · 2 revisions

Main features

  • Each statement terminates with a newline
  • The types and dimensions of all the variables are inferred
  • The default type for all variables is the C-type float. This can be changed while compiling a file.
  • All the variables will have the same type
  • There is no type checking done. So for example, if you assign an array to a number, this compiler won't throw any errors but the C compiler obviously will.
  • Refer to benchmark/source for more examples of what can be done with this compiler

Equation

A simple equation can be written as:

a = b + c

Forall

A Forall construct can be written as:

forall(i) where 0<=i<=100 {
    // Do something
}

Unicode characters can also be used, to give it a more mathy feel:

∀(i) | 0<=i<=100 {
    // Do something
}

The constructs inside a forall construct can be any type, a simple equation, a summation/product equation, or a forall node itself. There is no limit on the levels of nesting supported by this. But of course, C99 has a limit of 127 levels and this compiler generates C code. So keep in mind not to nest more than 127 loops.

Sigma / Product Pi

A Summation/Product construct can be written as:

sum = sigma(a[i]) where 0<=i<=100

Unicode characters can also be used:

sum = Σ(a[i]) | 0<=i<=100

The expression inside the sigma construct has to be a simple expression involving multiple terms and operators

Clone this wiki locally