Comments (5)
Check out the MapScope
implementation in https://github.com/spy16/sabre/tree/namespaced-scope.. I did a simple implementation of Clojure like Namespaces (Has ns
to switch namespace, has *ns*
that resolves to current namespace name). This does not support sub-namespaces and it is more like Go packages. Let me know your thoughts.
I have also used /
as namespace separator because, i do want to add support for method invocation and .
is more conventional approach for that.
Note: I haven't merged this to master and haven't decided wether I should merge or not as well. Like you said, not yet sure if this should exist as part of sabre
package itself or not.
from sabre.
I've been thinking about this too. Importing files is definitely needed. And that would require some isolation between imported things. May be some basic version of namespaces should be done in sabre itself.
One simple approach you can use is to implement scope interface and make sure everything passed to Bind call is done with ns/name
format. You can even support automatic resolution of namespace. For example, if user enters only foo
you resolve this to current-ns/foo
in your Scope implementation. Same trick goes for imported files. Implement import function that uses filename or a ns
header and binds all the values from the file with that namespace.
from sabre.
May be some basic version of namespaces should be done in sabre itself.
Sure, that would be helpful, especially if the facilities provided by Sabre are minimal and unopinionated.
Specifically, I don't think Sabre should force any particular syntax upon the user. I'm deliberately trying to avoid Clojure's import-path syntax, which mixes various types of separators (e.g.: (clojure.core/refer-clojure)
), and do something more like this: namespace.sub_namespace.some_function
.
Maybe Sabre should just provide an example of your suggested implementation (e.g. in the REPL rather than the sabre
namespace) ? It seems like a good first-step that doesn't close any doors.
from sabre.
Ok, after thinking about this some more, I'm still stuck. This is very much a language design issue, but if you have any insights, I'd be most appreciative!
What you describe above solves the problem of encapsulating symbols within a namespace, and it makes perfect sense. I'm still stuck on the second piece of the puzzle, though: how can I implement the switching of the current namespace?
In Clojure, I can create a new namespace and set it as the current namespace (= *ns*
) as follows:
user=> (ns my.new.namespace)
nil
my.new.namespace=>
Do you have any insights on how this might work in Sabre?
(I think this is where it might make sense for Sabre to provide some functionality ... maybe.)
from sabre.
Closing this as it's largely addressed by the example in branch slang
.
from sabre.
Related Issues (17)
- Support for metadata on symbols and collections
- Support for macros & special forms HOT 4
- Migrate parens standard library to sabre HOT 3
- Cannot build with GO111MODULE=1 HOT 8
- Member access for Go types from Sabre HOT 12
- Moving Slang to separate repository HOT 2
- Support goroutine invocation HOT 4
- Refactor Value interface HOT 2
- Macro expansion mutates original list
- FYI: Clojure implemented in Go
- how to implement comments HOT 6
- golang package and test best practice HOT 8
- export more internal functions from specials.go HOT 11
- Sabre Experience Report HOT 11
- Invoke on List type
- Archive Sabre HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sabre.