-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Protocols #21
Comments
To clarify: the above idea could accomplish the following goals:
|
@lilactown Sounds like good goals, but need to learn a bit more:
|
|
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/ |
@lilactown I've read the articles and this seems the way to go forward, agreed! |
This idea excites me: https://twitter.com/borkdude/status/1560711024336150528 |
An amendment to the initial design: by using |
Closing this as the general approach seems to work. Additional issues will be opened for gaps & bugs. |
Right now, protocols generate a LOT of code. This makes it sort of hard to justify using it for a lot of standard library stuff.
In JS practice, protocol-like extensions are done using
Symbol
s that are added to objects as properties. The symbols allow one to guarantee that there will be no conflicts with other code extending it.The way I think this could work is like the following. For code like:
It would generate the following code:
Extension would mutate the object, adding symbol as a property:
The text was updated successfully, but these errors were encountered: