In F #, let recit allows you to refer to a binding inside a function before it is bound. let recdoesnβt have an implementation as such, because this is just a compiler hint.
In this contrived example
let rec even =
function 0 -> true | 1 -> false | x -> odd (x - 1)
and odd =
function 0 -> false | 1 -> true | x -> even (x - 1)
compiled IL translates very secretly into:
public static bool even(int _arg1)
{
switch (_arg1)
{
case 0:
return true;
case 1:
return false;
default:
return odd(_arg1 - 1);
}
}
public static bool odd(int _arg2)
{
switch (_arg2)
{
case 0:
return false;
case 1:
return true;
default:
return even(_arg2 - 1);
}
}
All function definitions are statically compiled in IL. F # is ultimately a language that runs on the CLR. There is no meta programming.
source
share