Loon is a stack based, lisp looking, not lisp
While loon's syntax does look quite a lot like some other languages it ismore akin to a simple, very naive, lambda calculus interpreter which is built in such a way that combinators are its best friend.
Dec 27
Loon is really coming into its own, though I really want to reimplement it. (for like the 11th time not exaggerating). Here's what some code looks like in it for reference:
(= .. (λ a (λ b (λ c (λ d (a (b c d)))))))
(= fact (λ n (
== 1 n
(λ _ (1))
(λ _ (* (.. fact - n 1) n))
!
)))
(fact 4)
// end code
This program would output 24 as that is what the stack evaluates to. It evaluates the stack top to bottom, right to left, programs are simply a predefined stack to evaluate. Assignments ('=') evaluate to nil, which in loon is the identity function, so they are evaluated then discarded from the stack. Booleans use the church encoding (see lambda ) so the traditional 'if' control structure is just applying a boolean to two values and returning the result. In this case the result is a lambda (in order to support the recursion in the function) so it is then applied to the aformentioned nil (!) as a placeholder arg. This particular program makes use of the blackbird combinator (..) to save a parenthesised block.
I want to find other ways of getting rid of parenthesis in loon. My current idea is to implement something similar to the '$' symbol in haskell. Ending function definitions with 500 parentheses hurts me. I also want to perhaps implement a macro which turns λ a.b (exp) into λ a (λ b (exp)) which could also really help with that issue. Though it feels kind of hacky.