C² Language Design Notes

Hello World

static class HelloWorld {
    static int Main(string^[] args) {
        System.Console.WriteLine("Hello World");
        return 0;    


* Parts of this is not yet implemented!

Looks like C# except for the ^ (hat) close to the "args" parameter.

Everything is an Object

Everything "is" an object regardless of whether it is a reference or a value.

References vs. Pointers

Not yet implemented.

What determines how an object is going to be treated is the kind of variable declared.

There are 3 kinds of variables:

  • Value variable
  • Reference variable (^)
  • Pointer variable (*) - in an Unsafe context

Variables and Object allocation

Values are allocated on the stack and gets copied while assigned to new value variables.

A reference variable (^) is a safe reference to an object. The object gets allocated on the heap (using the new operator or malloc function) and automatically gets deallocated by the compiler once it goes out of scope. This is determined via reference counting.

In an unsafe context, a pointer variable (*) references an object at a certain hardware address. The compiler does not keep track of the object and does not deallocate it. It is up to the programmer to keep track of his own garbage. Overall, pointer references are similar to safe references but without the overhead.

Referencing objects

It is NOT possible to assign to a reference variable (^) a reference to an object that has been allocated on the stack. It would introduce complexity and unexpected behavior if one could to that.

In an unsafe context, it is possible for pointer variables (*) to reference any object at ones own risk.

Last edited Jun 23, 2014 at 7:51 PM by RobertSundstrom, version 6