Comments (8)
This idea excites me: https://twitter.com/borkdude/status/1560711024336150528
Bringing your own immutable collections and add support via protocols for assoc
etc.
This would still get you the features from CLJS but in an "unbundled" way.
from squint.
To clarify: the above idea could accomplish the following goals:
- Emit far less code than we do today
- Allow JS code to easily import and extend ClavaScript protocols
- Allow ClavaScript code to use JS protocols like the transducer example
from squint.
@lilactown Sounds like good goals, but need to learn a bit more:
- What is the benefit of using a symbol over a string here? When you create Symbol/for + a same string you will have an identical symbol and thus a conflict, similar when you would just use the string?
- Is it really that much different from what clava generates now (based on code borrowed from CLJS)?
- Which transducer example?
from squint.
Symbol.for
is an explicit lookup in the global symbol table. It is different than someone randomly calling theobject.bar
method, which may have a conflict. The other thing that symbols ensure is that the properties don't show up in things likeObject.keys
andJSON.stringify
, which is an improvement over using a long obscure string.- It's fairly similar in semantics, but right now Clava generates a lot more code than I wrote above. The code I wrote out also moves all handling of arity into the method implementation, rather than the protocol wrapper, which is more JS-like.
- It's linked in the OP: cognitect-labs/transducers-js#20
from squint.
Other examples of built-in "protocols" that could guide us towards a more JS-like design: https://dmitripavlutin.com/detailed-overview-of-well-known-symbols/
from squint.
@lilactown I've read the articles and this seems the way to go forward, agreed!
from squint.
An amendment to the initial design: by using Symbol("Foo")
instead of Symbol.for("Foo")
, we no longer have to worry about collisions, since symbols constructed the former way have unique identities each time.
from squint.
Closing this as the general approach seems to work.
Additional issues will be opened for gaps & bugs.
from squint.
Related Issues (20)
- Improvement: use arrow functions instead of "function" for implicit iife
- optimize function definitions for esbuild HOT 6
- `squint/core` Shuffle function suggestions HOT 2
- `squint/core` Prefer slice over pop HOT 4
- cljs is not defined when using `case` HOT 3
- Squint remove ":" for keyword value HOT 16
- class definitions not showing in repl HOT 14
- `nil` keys in map HOT 3
- zipmaps are disordered HOT 3
- `nil` causes a crash in html rendering HOT 1
- html renderer crashes when rendering nil from variable
- How to emit try catch? HOT 3
- REPL fails with `(extends class-1)` in defclass HOT 10
- `html` spread `nil` HOT 1
- Support `js$console` for requiring global libs
- (:query req) or (get req :query) not working on express request object
- could squint be used as a clojurescript compiler to javascript, output of which works with Scittle? HOT 3
- Macros get resolved as normal functions HOT 1
- HTML is not escaped in dynamic expression HOT 1
- logical not is not working
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 squint.