Skip to content

Syntax and coding style

Paolo Angeli edited this page Sep 21, 2019 · 27 revisions

A tiny taste of the language

Some comments

// Simple one line comment
/* Multi line comment */
/* A strange /* nested */ comment */ 

Some constants

RED::0x04586;
PI::3.14;
PLAYER::"Unnamed";

Some variables

counter : int;
mode := 10;
area : float = r * r * PI;

Some procedures

main_loop(){
  while 1 {
    get_user_input();
    simulate();
    render();
    post_process();
  }
}

do_something :: (what: string){
  printf("I'm doing: %", what); 
}

Some functions

square :: (val: float) -> float {
  return val * val;
}

circle_area:: (radious: float) -> float {
  return radious * radious * PI;
}

Some aggregated data type usage

Spring :: struct {
  relaxed_length : float; // millimeters
  theta          : float; // N/m
  force          : float; // N
  current_length : float; // mm
}
a_spring: Spring;
using a_spring {
  relaxed_length := 100;
  theta := 1000.0;
  force := 25;
  current_length = theta / relaxed_length * force + relaxed_lenght; 
}

Types, constants and variables

  • Variables and assignments
  • Language data types
  • Simple user-defined data types
  • Expressions and operators
  • Type-casting
  • Pointers

Flow control

Procedures and functions

  • Declarations
  • Arguments / Parameters
  • Return values
  • Overloading / Polymorhism
  • Advanced features
  • Lambdas

Aggregated data types

  • Arrays
  • Strings
  • Composition of Structs

Advanced features

Clone this wiki locally