-
Notifications
You must be signed in to change notification settings - Fork 15
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
Class extension/what is primitive #49
Comments
How is upsert a high-level operation? It's largely a shorthand for |
And yes, the addition of any new method to base classes may require your subclass to implement it as well - this is just how JS works. |
I mean, my thought is to have |
anything with |
Ah, true. It could still trivially be |
Sure - and then you're at the original design of this proposal, which additional constraints caused to change to look like it does now. |
Hmmmmmm |
But would you? Can't your subclass just inherit the base implementation of upsert and have it just work automatically, due to polymorphism, assuming that you've already overwritten |
No because Implementers of the |
Ah but that is a problem |
Oh, I didn't know, sorry about that. Where did you get this information? At least the current core-js polyfill is polymorphic on |
I was going by the README. Also see #47 |
The proposed API has significant problems for class extension. I'd argue that this is because
Map
is actually a primitive type, andupsert
is a very high-level operation that does not belong on such a primitive type. I know that primitive and high level types are an extremely fuzzy distinction in JS, mostly because ofArray
, which is both the lowest level and highest level construct in the language. I thought we were determined not to repeat the mistakes ofArray
-- to have low level primitives be distinct from high level functionality.For one thing,
Map
isn't just extensible -- it's designed to be extensible, or even usable as an interface. Just a few days ago I created a class for grammar productions. It implements theMap
interface, except thatproductions.get('Literal')
might returnproductions.map.get('Node')
. Rules about nodes apply to literals.If this proposal were to pass, I'd have to implement
productions.upsert
(or I would if my structure were mutable, which, it could be). The likelihood of my implementing an operation as complicated asupsert
correctly are low.The text was updated successfully, but these errors were encountered: