Wednesday, April 8, 2015

C++ Backend Part2


New syntax and built-in functions have been added to Rusthon's C++ transpiler to make interfacing with external C++ libraries as simple as possible. Namespace syntax is supported using ::, just like in normal C++, more info here. Macro syntax is support with the macro function (to inline simple macros) and new with statement with T as "foo(%s)": that makes T a callable macro, this is useful for calling template functions from external libraries, more info see here.

Functions can also now use C++ type syntax to define the function return type. This allows you to override the default behavior of returning shared pointers (to objects, arrays, and maps).

  • def f()->T* returns a pointer to T
  • def f()->T& returns a reference to T

Calling methods on strings has now been fixed and always works, before there was the problem of pointers|references (which the transpiler had to keep track of). This has been fixed with a c++ template class function, the transpiler when it is not sure what the type of something is will use this template function to properly wrap the value. This also solves the general problem of working with objects from external c++ libs, where you are not sure if something is a pointer, or a pointer to something.

No comments:

Post a Comment