ObjectC icon indicating copy to clipboard operation
ObjectC copied to clipboard

A library to use as a superset of the C language adding a lot of modern concepts missing in C

ObjectC

This project is a library to use as a superset of the C language.

It offers the following :

-Exceptions handling (try catch finally)
try {
 ...
} catch(TypeName, VarName) {
 ...
} finally {
 ...
}

-Classes, interfaces with Java like inheritance

class(Name, BaseClass, Interfaces...)
{
};

virtual(Name)
{
};

end_class(Name, OtherNames...);

-Introspection

Object tmp = new(String, ctorS, "Hello") as(Object); // as only needed when casting from object to interface pointer
isInstanceOf(String, tmp) // => true
dynamic_cast(String, tmp)
const char *method(toString) = getMethod(tmp, "toString");
invoke(void, tmp, "toString");

-Python Yield (co-routine, generators)

yields(int) range(int begin, int end)
{
    for (int i = begin; i < end; i++)
       yield(i);
    yield_break(int);
}

int main()
{
   for_yield(i, range(0, 5)) {
     printf("%d\n", i);
   }
   return 0;
}

-C++ life-cycle (RAII) -C++ rvalue reference -C#-like syntax for { get; set } (axors) -private member and public methods -foreach() keyword using coroutines (yield) -override of methods -etc...

Features to come (See Future/ ):

-Chained method call -Python's format for strings -A wrapper for gcc to add extra features and simplify syntax and improve error debuging -A true ref counting system without loosing RAII -scope(...) principle from Dlang -A custom ABI for methods described as follow : type name_'number_of_arguments'(...)

Disclamer: this project relies heavily gcc's extensions to the C language. Most of thoses exist in clang under a different name but not all. Therefore, for now, clang support is not a priority. Once we feel confident in tagging the project in 1.0 then things may change. The main prority is to improve the language and implement the above features.

Thanks.