by Imbue · 16y ago · 0 comments
1. Use DeBruin notation for referring to bound lambda values positionally, instead of my current approach of actually using the lambda symbol in an associative list. (Don't laugh, it works.)
2. Change the C implementation so it just uses an array of longs for the whole working space, with integer offsets, instead of node structs with pointers. At that point the whole implementation will be "nothin' but int", and avoid malloc altogether.
3. Change both the Perl and C implementations so that I supply external function definitions as function pointers. Right now when a high-order function is reduced to a normal form (lambda form), I actually look at the name of the external function being called and do a big if-else on that. (Don't laugh, it works.) This will no longer be an option when I go with DeBruin notation. Besides, the function pointer approach will be a lot more solid, serious, and extensible.
Thanks for expressing an interest. When I'm a little more proud of my code and have something available for download, I'll announce it on HN.
You're right about the sandboxing too -- the Fexl interpreter runs with two limits: the maximum number of cycles, and the maximum amount of memory. If it reaches either of those limits, it halts. So it should be perfectly safe to run it on the public web.
The interpreter understands only the two fundamental combinators S and C. Although it is possible to define high-order combinators in the interpreter using function pointers, I am limiting myself to S and C to minimize the code size and illustrate the principle that all computable functions can be defined as applications of only S and C.
So, for example, even the Y combinator itself is defined in terms of S and C as:
\I = (S C C)
\Q = (S (S (C S) C) (C (S I I)))
\Y = (S Q Q)
I'm now doing some bootstrapping, eliminating code formerly written in Perl. I'm writing the Fexl parser in Fexl, and manually converting it to S and C. I can then eliminate the parser written in Perl.Here is the basic Fexl language, which can express all computable functions.
expr = \atom expr
expr = factor
expr = factor expr
factor = atom
factor = (expr)
The full language includes two additional notations for convenience.
expr = \atom=factor expr
= (\atom expr) factor
expr = factor; expr
= factor (expr)