-
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
Problems with with #55
Comments
Yeah, having the operator behavior change mid-block seems really bad. It should apply to the entire block scope (hoisted). |
How about throwing a syntax error if any I personally would prefer this proposal to be split into two proposals: the "operator overloading" part (likely non-contentious) and the "with operators from" part (which would likely be more opinionated). |
@Pandapip1 that would solve this one case, but would create new problems. You could never define a class and use its operators in the same file, which sounds rather stupid, but would be necessary as you cannot work on classes before they are defined (so you cannot put the with statement before the class definition). |
I think adding a new config option (like To clarify, there should also be an option to allow at least creating operators (for library creators), so I'm talking about removing |
@FrameMuse and how would you configure this? |
Config file? |
@FrameMuse and what config file? A new convention for browsers? Sounds a bit overkill for a single JS feature to work. |
Yeah, didn't think about it. |
I still don't think
Because if not including them all at once, then we have big problems inventing new structures, which engine developers don't like very much (at least for this minor feature). |
@FrameMuse I see a third solution: reimagine the proposal (although that would probably involve post-poning it). I have seen a few different approaches in the issues and came up with one myself. |
@Haringat I think you probably should create a new proposal since you have your own vision. This would be something like "define operator" as you suggested in this issue. IMO, this is a nice approach, I like it. |
I too like the approach you linked. The syntax (at least to me) seems better than the |
(aside from a slightly confusing issue title)
Imagine the following two files:
a.js:
b.js
what will r2 be? The
with operators from
statement in a.js is already parsed asaddWithOperatorOverloading
was used which is defined below that statement. Having the result depend on how far the file is parsed/executed would cause a lot of ambiguity and would be a hassle for the engine to sort out but having the statement have effects on higher lines in the file would clearly be unintentional.And how are bundlers like rollup supposed to handle this? The following (naive, but in line with how bundlers work) approach would not be acceptable as it would cause intended leak of operator overloading into higher code:
bundle.js
Here the value of r2 would be even more ambiguous as
addWithoutOperatorOverloading
is clearly called below thewith operators from
statement.The text was updated successfully, but these errors were encountered: