compiler_experiment

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.deepztream.com/compiler_experiment
Log | Files | Refs

input.dc (613B)


      1 // Basic 2 dimensional vector
      2 typedef Vec2i: struct {
      3   a: int;
      4   b: int;
      5 };
      6 
      7 /************************************************************
      8  * Operator overloading for `Vec2i + Vec2i`                 *
      9  * /* Now we have the ability to support nested comments */ *
     10  * Returns a new `Vec2i` with it's elements being           *
     11  * the result of element-wise summation of the operands.    *
     12  ************************************************************/
     13 
     14 operator[infix, prec('+')] + (left: Vec2i, right: Vec2i) -> Vec2i {
     15   var result: Vec2i = left;
     16   result.a += right.a;
     17   result.b += right.b;
     18   return result;
     19 }