-
Notifications
You must be signed in to change notification settings - Fork 903
Changes to function signatures in preparation for better spec compliance. #2050
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
base: master
Are you sure you want to change the base?
Conversation
|
Needs a rebase for new set methods, I’ll do that later today, but it shows how widespread this change is, at least inside our code base. Outside our code base I think the largest effect would be on classes that do the whole |
|
Would it be possible to write down somewhere, in an issue or discussion, possible fundamental changes to top-level objects like this? I actually think that we can handle a change like this in the project, but if we're going to go and do surgery on Callable and Constructable, we might as well do it once and for all! |
7385826 to
c46e824
Compare
c46e824 to
94fb3ce
Compare
94fb3ce to
bb95340
Compare
|
There are so many things to think about with this, since I think it will affect many projects that integrate with Rhino (but that doesn't mean that we shouldn't do it, just that it might be "rhino 2.0") Two generic questions first. What do you think?
|
|
I am inclined to say that I think scopes need to support delete because of the delete operator, but I will check on the restrictions in the spec. I’ll keep playing with this for a while before taking this out of draft. I am not sure where associated values belong (can they be internal slits?) and whether we can separate the two concepts further without making the compatibility story harder. the current prototype does have the advantage that it is mostly a mechanici Change for downstream users. I did play around with some default implementations to make things easier, but for the general case they actually made it way easier easier to introduce subtle bugs. I’ll create a couple of ancillary branches to show the other possible approaches. |
Ah, |
|
Also, what do you think of "Scope" instead of "JSScope"? Does that create a conflict somewhere else? I think it's clear and looks nice and we already use super-generic terms like "Context" so it's not like it'd be a new precedent to use a popular term. |
|
Wish that "Comment" and "Close with Comment" button weren't so close together! |
|
I had used |
I've been thinking about this. It’s mostly historical, and allowed for a fairly minimal API change. Maybe we can do something that separates the two concepts more fully, but I think that might have a lot of knock on effects because i don’t think we reliably distinguish between scope access and property access in our IR. We do need something to pass in to some of slot map APIs, but maybe we could have a super class of scope and scriptable and handle it that way. |
|
Unfortunately I think whole idea of separating scopes and scriptables may be slightly flawed. As I had previously noted and in a compliant implementation that should print Luckily that seems to be the limit of Object Environment Record use in the spec, so this might still be doable. |
|
Getting rid of parent from scriptable requires fixing a bunch of places where we don’t pass a scope through. I think that’s all doable but might be best done in a separate preparatory PR. I think I also need to go through the spec regarding realms to be sure we aren’t going to cause problems down the road on that front. |
|
I'm continuing to pick away at this, and may soon have a set of preparatory PRs. I've had a couple of "Ah ha!" moments that have really helped on this:
My goal is to remove every use of |
|
Passing the scope explicitly creates a huge amount of change, I'm not convinced it's worth it and it would make merging this into forks horrible, it's hard to even stage it into more manageable chunks without some fairly severe refactoring to our I'm going to try a plan B of maintaining the current scope on the |
|
Hmm, plan B isn't great for benchmarks in some cases. It establishes a reference from a long lived object (the context) to a lot of short lived objects (activation frames) and so after a while GC starts to be much more problematic. In a lot of cases contexts are short lived and this isn't a problem, but if they are longer lived then it can be a problem. I mean, we already have this for the interpreter (where we maintain the current frame) but this would add that for compiled mode as well. |
|
Okay, plan B wasn't working out nicely at all, so I went back to thinking about why I needed to pass a scope around. Mostly this was to use in calling function objects which should in general be being passed the scope they were declared in. There were a couple of exceptions to this in the code, but as far as I could tell they were potential bugs and fixing them hasn't broken any 262. tests. So I've introduced a default method on The one exception to this is property descriptor creation, but that is proving much simpler to sort out (they need to get the This is all looking much more tractable. |
Maybe we can start by addressing them one after another with simple PR's. This way they don't get lost and we made some progress; and maybe having a more complete test suite. And great to see al this deep design work... |
|
Yeah, that seems reasonable. I was thinking they were something that should be separated out from the more mechanical changes anyway. |
|
Another ah-ha moment. While going through adding the scope to property descriptor stuff I start to ask myself which scope should be passed in by proxy operations. The caller’s, the proxy’s , or the target’s and how this might affect things. Off to the spec I go… The answer is actually none of them! The real problem we have is that we have conflated the internal method Disentangling those might make this a whole lot easier. |
|
Making good progress on this. I've spent some time today removing uses of The remaining Next step is to start the series of changes to separate Currently there are six failing tests around |
|
Just a quick update. I have a branch with all but 34 tests passing and scopes and scriptable separated with a common ancestor. I have introduced a
Happy for feedback on the above, @gbrail, @rbri, & |
I don't have strong opinion here, I trust your judgment. A feature flag sounds a good compromise.
I am not 100% sure I understand. You mean keep a smaller public interface in
We talked about this. I think trying to do that in a separate PR would be a bit better purely for review purposes - this one is going to be giant as is :-)
What did you have in mind?
How can you implement parent in a backward compatible way (i.e. point 1) if you don't make it mutable though? |
I think I'm just worried that many of the existing property access methods have had to pull double duty for scopes and objects, and sometimes rely on complex logic along with
Agreed, I think it's one to try and land before the main scoping changes because it makes them much simpler. I'll try and separate that out.
I was thinking we would want a method like
It only needs to be mutable for |
There are a few functional interfaces in our code which don’t line up well with the spec. Putting this here so we can think about the impact of changing these, or whether we should introduce new interfaces, deprecate the old ones, and look for some combination of overloading and default implementation to maintain compatibility.