-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
extending JS builtins #242
Comments
Thanks. I think this might be due to how the words |
Hmm, using
|
This might be an issue with how satisfies? is implemented in SCI when you have no methods. This seems to work:
|
Reading the source of
this is due to how SCI's |
version
v0.6.129
platform
macOS 12.4 + Nodejs v18.3.0
problem
ClojureScript allows extending protocols to built in types like strings, numbers and general objects without mutating their prototypes by using special "type symbols." This is documented in the docs for extend-type. See this google groups discussion for more discussion.
nbb
might not need to worry about mutating the prototype - I haven't dug into how nbb & sci implement protocol dispatch - but I think we ought to support CLJS libs that follow this convention, such as my own cascade which extends a protocol to theobject
symbol.repro
There's slightly different behavior depending on what "type symbol" one attempts to extend.
Most of them print an error message at the REPL.
However, some of them seem to succeed but don't have the desired behavior.
nil
stands out as seeming to work, but doesn't seem to actually extend the protocol tonil
values.array
andboolean
do something even weirder: they extend the protocol to the corearray
andboolean
functions, which doesn't have the desired effect.expected behavior
Extending a protocol in any of the ways above would not result in an error, and would ensure
(satisfies? IFoo x)
would return true for the valuex
of the associated built in created by either literal or constructor.The text was updated successfully, but these errors were encountered: