Handmade Network»Christoffer Lernö

Recent Activity

Christoffer Lernö
Christoffer Lernö
Christoffer Lernö

I finally added a syscall compiler builtin:

Here is an example showing the latter but also clearly how the temp allocator can hand over to the backing allocator for pages which also gets cleaned up as needed:

Swapping the normal allocator for the temp one and clean after use:

Temp allocator with autoreleasing pools:

I bumped C3 to 0.3.0 basically it's just all that was after 0.2.0, which I first released as 0.2.1 0.2.2 etc. Even though I've had problems with eyestrain during and a lot of time spent is just thinking about how a feature should look, it ended up being a bunch of things added:

Some enum name reflection, with opt-out:

C3 doesn't have function overloading but:

New blog post: Optional syntax
Christoffer Lernö

Getting somewhere with the printf, the snippet below is now printing:

0: deadbeef 1: 0x00007ff7bf0b0608 🤣 [0x4d2] -43943922244 +123 -12 2: -43943922244 -43943 123 -12.300000 3: -1234.300000 你好 Hej 4: 1.230000 45.000000 1.23000 45.0000 1 45 2.382300e+02

Working on printf:

Christoffer Lernö

Adding a string builder in the standard library for C3:

New blog post: Imports and modules
Christoffer Lernö

Converted the Raylib Arkanoid, which unearthed a bug in the ABI implementation! Excellent.

Playing Snake with Raylib + C3:

This is a first stab at a library description format for C3. This example defines only a single target (MacOS x64), but normally more are added. Using --lib raylib this definition would link libraylib.a + all of the MacOS frameworks. Note that rather than providing a statically allocated library, the same definition file could allow a directory of .c files or .c3 files to compile. Or link it dynamically.


ERROR: '@require "d > 0" violated.'
  at function test::test (debugstuff.c3:4)
  at function test::main (debugstuff.c3:10)
  at function test::_$mainstub (debugstuff.c3:8)

This prints:

Assertion failed: (@require "baz > 100" violated: 'whatever'.), function test, file debugstuff.c3, line 6.
Christoffer Lernö

Last piece of compile time constructs:

Just reducing the code output to LLVM on -O0 (an extreme case, reducing the number of instructions from 12 -> 3)

Christoffer Lernö

Some updates to the variant functionality - either get it as pointer or as the value copied to variable:

Not finished, but this prints

double 123.000000
int: 1
Unknown type.
New blog post: Some C3 Advent of Code
Christoffer Lernö

Ranged case Output:

Something else: 0
Something else: 11

I made this, which outputs:

3 12
1 7

Adding some volatile store/load:

New blog post: C3 Feature List
Christoffer Lernö

Testing the bitstruct

Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
New blog post: How to break a + b + c
Christoffer Lernö
Christoffer Lernö

I've been implementing some of the programming language shootout tasks... here is mandelbrot:

C3 got string (actually slice) matching. This outputs

This works
This works too

So this experimental stuff works now with this output:

Hex array: Open the pod bay doors
Base64 array: Open the pod bay doors
Multi line:
Say hello,
to my little friend...
Raw string: C:\foo\raw.dll

The whole new try stuff is added to C3 now, and I enhanced it a little:

A contributor made raylib bindings for C3: 🥳

First version of user defined foreach works, this prints


Thanks to the hard work by the contributor kvk1920 C3C is now up and running on Windows under Mingw and MSYS2 with CI! 🥳

I had to do ad hoc lexing for feature, but I'll end up reusing it for a lot of other compile time functions later on:

Doing test_param(11, 10); gives:

Assert violation 'Invalid input' on line 159, in file 'debugstuff.c3'.

This prints:

157: /**
158:  * @param x - one parameter
159:  * @param y - other parameter
(debugstuff.c3:159) Error: There is no parameter 'y', did you misspell it?

Getting more environment info available from inside of programs now.

Christoffer Lernö

So this now works, with an output of:

Repeat 1
Repeat 2
Repeat 3
Repeat 4
Repeat 5
Repeat 6
Repeat 7
Repeat 8
Repeat 9
Repeat 10
111 121 4 77 

I added this for enums, it's sometimes useful (printing Min -5 Max 14 Elements: 3)

C3 got a new style for casts:

Finally some generic module code up and running. Defining some parameterized functions and types.

Those cursed gradients are working again for text rendering:

Sum integers using recursion, slices and typed varargs... 😅 (call using sum_us(1, 3, 5, 11))

Ok so this works now, but it's using alloca to copy the slice. I don't know how I feel about that. In safe mode you'll get a panic if you exceed MAX_PARAMS, but currently not in non-safe. I might mask this though.

A goddarn miracle, C3 is using built in linking on Linux

Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Forum reply: Welcome everyone
Christoffer Lernö
New blog post: Implementing "defer"
Christoffer Lernö
Christoffer Lernö

Piecemeal adding some welcome library functionality while checking how the macros/function namespacing looks in the wild (not perfect yet):

Took a little while but constant aggregates are now spliced in a fairly efficient format from what I can see. This one would take gigabytes of memory to describe for Clang:

More and more debug info getting done in the C3 backend:

New forum thread: Welcome everyone
Christoffer Lernö