1.5. Operator dot

It may look as if Felix knows how to access the components of a Felix struct value using operator dot. Strangely enough, this is not the case! When you write:
  expr.name
in a value context, it is translated to the function application:
  get_name expr
To illustrate this is really the case, consider the following example.
Start C++ section to tut/examples/tut_bind133.flx[1 /1 ]
     1: include "std";
     2: 
     3: // part 1
     4: header """
     5: struct gauss
     6: {
     7:   int x;
     8:   int y;
     9:   gauss() : x(0), y(0) {}
    10:   gauss(int _x, int _y) : x(_x), y(_y) {}
    11: 
    12: };
    13: """;
    14: 
    15: type gauss = "gauss";
    16: fun get_x: gauss -> int = "$1.x";
    17: fun get_y: gauss -> int = "$1.y";
    18: fun mkgauss: int * int -> gauss = "gauss($1,$2)";
    19: 
    20: val z = mkgauss(1,2);
    21: print z.x;
    22: print ", ";
    23: print z.y;
    24: endl;
    25: 
    26: // part 2
    27: struct X {
    28:   x : int;
    29: }
    30: val i = X(1);
    31: print (get_x i);
    32: endl;
    33: 
End C++ section to tut/examples/tut_bind133.flx[1]
In part 1, the functions get_x and get_y are defined by binding, but the dot notation is used to call them.

In part 2, the functions get_x and get_y are defined by defining a struct, and they're called directly, without the dot notation.

The dot notation is just syntactic sugar for calling a get function.

What is more, the struct definition is just syntactic sugar for defining an abstract type with some get functions (as well as a constructor).

What this means is that for an arbitrary C++ type, you can create an abstract binding, and define get methods which can be called using dot notation. Just name the methods 'get_' something.

It is also possible to access a Felix struct from C++, although we'll defer disucssion of the C++ representation of Felix data structures until later. [The C++ name of the struct type is not the same as the Felix name]