ALPHA: breaking changes expected. What that means
NanoC

Types

NanoC does not invent a type system. Types are a small set of sized names, prefix pointers and your own record, enum and typedef names; other C spellings go in backticks.

Today: C types

Typedef names such as uint8_t and your own s, u, e types are passed to C as written. Prefix pointers use *T. C spellings such as unsigned long or struct stat are written in backticks, as in long .

NanoC
+stdint
s Pair a,b: i32
f main
  p: Pair = {84, 36}
  small: uint8_t = 200
  big: int64_t = 1099511627776
  x := 2.5
  p.a + small + (int)x - 286 != 0 || big == 0
C
#include <stdint.h>

typedef struct Pair Pair;
struct Pair {
    int a,b;
};

int main(void) {
    Pair p = {84, 36};
    uint8_t small = 200;
    int64_t big = 1099511627776;
    double x = 2.5;
    return p.a + small + (int)x - 286 != 0 || big == 0;
}

Inference with :=

name := literal infers a C type from a literal only: 0 gives int, 2.5 gives double, 'a' gives char, a string gives const char *. Calls, arithmetic and names need an explicit type: name: Type = expression.

Target: sized types

The new core drops platform-dependent spellings. Every scalar has one name and one size.

NameMeaningC type
i8 i16 i32 i64Signed integersint8_t to int64_t
u8 u16 u32 u64Unsigned integersuint8_t to uint64_t
f32 f64Floating pointfloat, double
boolBooleanbool from stdbool
charCharacterchar
strText pointerconst char *
sizeObject sizesize_t
ptrUntyped pointervoid *
NanoC, new syntax (preview, not compiled yet)
n := 2
big: u64 = 1 << 40
f scale(x: f32, k: i32) f32
  x * k