Closed spy16 closed 4 years ago
@lthibault Any thoughts on this? I was thinking a package slang
can have a simple usable language implementation with REPL, name-spaced scope using Sabre . This package can act as a reference usage.
Ah, wonderful! This is a huge help in understanding how the pieces fit together 👍
I'm going integrate some of the design of Slang into my own project and then post it to github. If you're interested, it might provide some useful insight into how I'm using the library.
@lthibault take a look at https://github.com/spy16/sabre/pull/6/commits/679889252ed6020ac704dc76265dfb85c4f6763c. It implements our discussion. I went with repl.Loop(ctx)
function. Any thoughts on that (i.e., Run(ctx)
vs Loop(ctx)
)?
While repl
has turned out be a nice little package, i think the Runtime
interface adds a bit of unnecessary complexity. For building a custom language, all that is really necessary with Sabre
is to bind custom functions into a Scope
implementation and pass this scope + forms to sabre.Eval
. Historically also, LISP had concept of Environment against which data structures/forms/s-expressions are evaluated. I am thinking may be it would be good enough to have repl.New(env sabre.Scope, opts ...Option)
as the actual signature. Scope can implement an optional interface to support namespaces.
type NamespacedScope struct {
SwitchNS(ns string)
CurrentNS() string
}
This would make the REPL usage much simpler since user doesn't really have to manually implement any interfaces.. repl.New(sabre.NewScope(nil), ....)
would work for most cases.
+1 for eschewing repl.Runtime
in favor of sabre.Scope
. Also agree with the optional interface approach to providing namespaces.
@lthibault I have changed inline function to ErrMapper
type and also added WithReaderFactory
to allow customizing reader initialization. Let me know what you think..
Also, currently, binary is available as sabre
(because of cmd/sabre/main.go
). But given that the binary actually running slang
as the runtime, do you think the binary should be available as slang
(i.e., cmd/slang/main.go
) ?
Do you think the binary should be available as
slang
?
Yes, I think that's a good idea. I initially started a cmd/slang
package because I hadn't noticed that cmd/sabre
was doing what I wanted ... so I'm sure that will confuse others, too!
Reviewing changes now.
All fixed. I think it is good time to merge this to master and continue from there.
@spy16 can we increment the version tag too?
Yes will do that. v0.2.0
? (Still not mature enough to be v1
i think. But big changes so minor release)
Yes will do that.
v0.2.0
? (Still not mature enough to bev1
i think. But big changes so minor release)
Yes, agreed on all counts.
BTW, I think this is ready to merge ... just want to make sure you weren't waiting on me! 😄
Ah thanks. But it was late night for me and decided to do it later. Will do it sometime today.
I want to cleanup the commits here a little bit before merging since there are lot of unwanted/experimental commits. Any ideas? Interactive re-base is getting lot of conflicts for some reason.
One other option is to squash and merge, but that will lose author information unless we add Co-authored-by
I want to cleanup the commits here a little bit before merging since there are lot of unwanted/experimental commits. Any ideas? Interactive re-base is getting lot of conflicts for some reason.
One other option is to squash and merge, but that will lose author information unless we add
Co-authored-by
Sorry, I was a bit slow to respond.
I'm generally a fan of rebasing into the master branch to the extent possible. If this situation ever comes up again, let's just discuss again at that point (and hope it doesn't happen to often!)
In any case, I very much appreciate your consideration of attribution. Thanks for that 😃
(P.S.: first collaborative PR closed! Woohoo! 🎉)
Yea i like to rebase onto master as well. But before that i also usually cleanup commits a bit by squashing some of them to make each commit a sensible and usable set of changes.
For this PR, i have included the Co-authored-by
section which shows up in this merge commit. But unfortunately it doesn't show in repository contributor list.. :(
No worries. There will be a next time 😃
Slang (short for Sabre Lang) - A tiny LISP dialect implemented using Sabre.