-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Final Design #7
Conversation
🎉 Added support for closures. ;; notice that the parameters are specified in pure-LISP form since we
;; don't have vectors yet.
(def foo (fn f1 (a)
(fn f2 (b)
(fn f3 (c)
(+ a b c)))))
(((foo 1) 2) 3)
;; returns 6 as expected,
(def adds3 ((foo 1) 2))
(adds3 10)
;; returns 13 as expected. 🎉 Added support for macro (with no syntax-quote/unquote support yet) (Refer #4) (def foo (macro (a) ''a))
(foo 10)
;; returns a as expected |
@lthibault This project has been stuck at the same incomplete/unstable state for a while now 😅. I think this PR finally has the base that we can build on. I would like to finalize a repo structure and make a release with these changes. Bit confused about what structure to go with.. Let me know if you any suggestions here. Approach 1
Approach 2
Approach 3
Approach 4
Or just everything in |
@spy16 This is really great!!! 🎉 🚀 🔥 Thanks for doing this! I flagged a couple of minor issues, but I think this is pretty much ready to merge at your convenience. In terms of package structure, I'm most favorable to approach 1. My reasoning is that since we're aiming for a build-your-own-lisp toolkit, a clear separation between core functionality ( Minor suggestion: I would go with Anyway, 👍. Merge when ready! P.S. I'm still using |
I think I finally found a satisfactory design for this. Some highlights:
Env
is an interface and only represents the context of evaluation. It does not do the evaluation. This allows customExpr
same set of facilties available for builtin Exprs.Env
provides aChild(name string, vars map[string]core.Any) Env
method that allows us to create a stack for a single thread execution. This is also necessary for supporting closures since we need to extend the closing environment for creating the func.Analyzer
andEnv
are separate allowing us to independently customize. This also means, we can have anInterpreter
type of struct that composes a reader, analyzer and env to give a single executor that can expose things likeReadEval
,Eval
etc. and also stacktrace generation etc.Note: This PR only has the final overall architecture model. But still needs some changes to be the final repo structure.
builtin.NewAnalyzer
does not let you set custom special-form parsers for now..builtin
package ( i did that to have some separation from already existing types during experimenting) - may be we should have it in the rootslurp
package itself.