EDDI Compiler 1.1.3 - Templates

I finished the version 1.1.3 of the EDDI Compiler (eddic).

The main improvement to the language is the support of templates. The syntax is more or less the same as the syntax of C++ templates, but the features are much more limited. In EDDI, you can declare class templates and function templates. Class templates can also includes member function templates.

Here is an example of the use of templates in EDDI:

template<type T>
struct node {
    T value;

    this(T init){
        this.value = init;

    T get_value(){
        return this.value;

    template<type U>
    void print_value(U v){

template<type T>
void debug(T t){

template<type T>
void test(node<T>* node){

void main(){
    node<int> first_node(100);
    node<float> second_node(13.3);



This new feature adds generic programming capabilities to the language.

This version also adds other language improvements. The first one is the support of the ! operator for a bool, to test if a bool is false. This version also includes support for iterating through all the chars of a string with a foreach loop. And finally, the this pointer is now implicit to access member fields of a struct from member functions.

The optimization engine has been greatly improved. The pointers are much better handled and some regression due to new features have been fixed. The Constant Propagation optimization can take default values of struct and arrays into account. Finally, the functions with char parameters can now be inlined.

Finally, the compiler use a new logging system, that can be completely removed at compile-time for release versions.

Future Work

The next version of the EDDI compiler (eddic) will be the version 1.1.4. This version will add support for some basic pointer manipulation. It will also add support for dynamically allocated arrays. Finally, the version will includes several new optimization techniques regarding to loops: Loop Invariant Code Motion, Loop Strength Reduction and perhaps some basic Loop Unrolling.


You can find the EDDI Compiler sources on the Github repository: https://github.com/wichtounet/eddic

The exact version I refer to is the v1.1.3 available in the GitHub tags or directly as the release branch.

Related articles

  • EDDI Compiler 1.1.0 - Member functions
  • EDDI Compiler 1.1.2 – Read command line
  • EDDI Compiler 1.0.1 - Pointers and better struct support
  • EDDI Compiler 0.6.0 : Arrays
  • EDDI Compiler 1.1.4 – Graph Coloring Register Allocation
  • EDDI Compiler 1.0.2 – Better pointer support and Dead-Code Elimination
  • Comments

    Comments powered by Disqus