ExpandCollapsePrev Next Index

+ 2.1 Combining bindings

Felix allows you to combine bindings with functions and procedures. We will starting with chapter 1 bindings:

  include "./intro_01";

hello world

+ 2.1.1 Felix procedures

A Felix procedure is a way to combine Felix procedures and functions as well as bindings.

  proc myprintln (x:myint) 
    myprint (x);
  myprintln (myadd (one,two));


Calls to Felix procedures can be though of as reducing to the calls in their definition, which in turn reduce, recursively, until the process bottoms out by reducing C++ bindings to C++.

Thus you can think of Felix has a giant macro processor for C++, although unlike the C pre-processor, Felix has a powerful type system to help prevent errors and guide overloading.

+ 2.1.2 Felix functions

A Felix function is a way to combine both other Felix functions and procedures and function and procedure bindings. For example:

  fun mytwice (x:myint) => myadd (x,x);
  myprintln (mytwice (one)); 


There are more advanced form of these constructions, but we're not ready to introduce them yet.