GitHub

Syntax Overview

A tour of Nexus syntax generics, pattern matching, memory semantics, and more.

Comments

Nexus has two comment styles. Single line comments use /* ... . Block comments use /! … !/. This allows us to have the two types of divisions shown later. (As of 1.3 there are no documentation comments.)

comment styles
/* This is a single line comment. It ends automatically at the end of a line.

/! This is a block comment. This will span multiple lines. !/

Printf(" Hello, world!"); /! returns Hello, world!/

Arithmetic Operators

Division in Nexus distinguishes between true division and integer (floor) division, avoiding the common pitfall of silent integer truncation.

OperatorMeaningExampleResult
/True division5 / 22.5
//Integer (floor) division5 // 22
%Modulo (remainder)5 % 21
+Addition3 + 47
-Subtraction9 - 45
*Multiplication3 * 412
++Incrementcpt++adds 1
--Decrementcpt--subtracts 1

I/O & String Interpolation

Nexus provides two print functions. Printf evaluates interpolation expressions inside { } at runtime. Print outputs the string literally — no interpolation.

printf vs print
Printf(" 5 /  2 = {5/2}  \n");  /* 5 /  2 = 2.5  */
Printf(" 5 // 2 = {5//2} \n");  /* 5 // 2 = 2     */
Printf(" 5 %  2 = {5%2}  \n");  /* 5 %  2 = 1     */

Print(" 5 /  2 = {5/2}" );   /* 5 /  2 = {5/2}   (literal) */
Print(" 5 // 2 = {5//2}");   /* 5 // 2 = {5//2}  (literal) */
Note: Anything inside { } within a Printf string is a full expression — you can call functions, do math, and access fields there.

Conventions

Conventions in nexus are quite simple

ObjectConventionExample
Functions/Classes/MethodsPascalCaseMain();
Variable/AttributeslowerCamalCasei32 numExample = 5;
ConstantsFULL_CAP_SNAKE_CASEprivate const i32 NUM_USERS;
Static Objectprefixed with g_/G_ private static g_GetTotalUsers();
IndentationUse tabs avoid spaces (personnal preference)

Note : Some of the object such as classes aren't implemented as of 1.3

Next Types