- lazy, so no side effects, because they can really mess up a lazy language
- untyped; Haskell is already there for typed, lazy languages
- metaprogramming; the eval function uses ASTs that are LC functions
- We'll rewrite Lazp's parser and code generators in Lazp, so it's self-hosting
- I "hand assembled" the AST functions, so they're in Lazp, already
- This means metaprogramming in Lazp can happen at parse time and also at runtime (hey, just like in FORTH!)
- _lit v -- literal value
- _ref v -- variable reference: v should be a string
- _lambda var body -- lambda binding: var should be a string or number, body is an AST
- _apply func arg -- function application: func can be any AST function except a _prim
- _prim arg rest -- primitive call: rest is either a _lit, a _ref, or another _prim (which allows more args)
- _name name ast -- name a type
- _lit x = λf . f x
- _ref x = λf . f x
- _lambda v f = λg . g v f
- _apply func arg = λf . f func arg
- _prim arg rest = λf . f arg rest
- _name nm ast = λf . f nm ast
So, what's already working? I had a big advantage, here, because I could use the Lambda Calculator as a prototype. So, right now, this returns "hello":
eval (_apply (_lambda x (_ref x)) (_lit hello))This calls eval with an AST that applies the identity function to "hello".
The code's in Coffeescript and the parser and code generator is all in one file with no dependencies, called Lazp.cs (about 375 lines of code).
I'm looking for help on this, so feel free to leave a comment if you're interested and feel free to fork it in Github; it's licensed with Zlib.