Banjo

52 thoughts
last posted Nov. 9, 2015, 7:13 p.m.

32 earlier thoughts

0

Recursive let idea

I was mulling over how to support mutually recursive functions in a nice way using let. A simply recursive function is passed itself automatically when it is called as part of the standard calling convention. However, in a situation like:

(
f1(x) = ... uses f2 ...
f2(x) = ... uses f1 ...
) => ... uses f1 and/or f2 ...

The functions don't immediately have any access to each other.

However, for this special case I realized that I could inline the definitions of functions in the same let block, but which come later, into the definition of a function.

So, in this example f1 wouldn't normally have access to f2 because it isn't defined yet. However, I can copy the definition of f2 into the body of f1 if necessary. This might require an analysis to decide which functions need to be inlined.

So the above could be translated to:

(
f1(x) = (f2(x) = ... uses f1 ...) => ... uses f2 ...
f2(x) = ... uses f1 ...
) => ... uses f1 and/or f2 ...

19 later thoughts