-
Notifications
You must be signed in to change notification settings - Fork 22
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
Predictability goals are confusing #36
Comments
I'm also unsure why this is an issue here, but not in the rest of JavaScript. To me, this rule seems to increase the complexity of the solution in terms of legibility and usability (having to add with operators, and having to use a separate construct that is external to the object). Unless I'm misunderstanding, it's this rule that prevents us from having a much cleaner and easier to understand API that would look more like this: class Vector3 {
//...
operator * (a, b) {
return new Vector3(a.x * b.x, a.y * b.y, a.z * b.z);
}
operator == (a, b) {
return a.x === b.x && a.y === b.y && a.z === b.z;
}
operator > (a, b) {
//...
}
}
const myObject = {
[*]: (a, b) => a.value * b.value,
[>]: (a, b) => a.value > b.value
}
myObject.defineOperator("-", (a, b) => a.value - b.value) And if you need to pass without operators: Object.raw(myObject); |
The same for us We want to change the behavior of old program, that's one of the point of meta programming. |
@rihok Option 2 could be a bit of a hazard to parse but I like option 3. Maybe replace the string with a unique well-known symbol and make it |
This one makes no sense, because it's already possible to do something like
This one again makes no sense, because as I understand that means you can't use operator overloads with non overloaded objects, but why? It's that the reason for op. overloads, to make fully customizability behavior or object manipulation during operator actions?
I guess i just misunderstood most of that two rules, could you please clarify it?
The text was updated successfully, but these errors were encountered: