-
Notifications
You must be signed in to change notification settings - Fork 45
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
names for Loader constructor and default loader #34
Comments
What's wrong with I don't like I would strongly favor it being lower-case whichever name is chosen, it's too hard to forget it's not a constructor otherwise. |
|
I like I think having |
I don't like I think I don't have a better suggestion. /cc @ericf |
Not to be argumentative, but why? It's pretty common to name constructor/instances in this way. I don't hate default either. My only qualm would be that you tend to use the loader more than you realize so |
Argumentativeness welcome ;-)
Fair point. I'm not sure I can justify my intuition. And maybe |
I really like |
I am also a bit concerned about |
Let me clarify my position, I want to see a very simple way to access the default loader without having to know that you can create more than one loader (as an advanced feature). |
@caridy The constructor is |
@matthewp I think he means the most derived constructor, in the case where the host environment decided to make |
@dherman Ah, yes, then as is normally the case, |
@dherman thanks for the SystemJS consideration, but don't let it be a drawback! Quite happy to have an etymological name. |
@caridy I think your position is the strongest. There's plenty of precedent for lowercase singletons sitting next to their uppercased constructor ( I think we should go with |
+1 to Side question: Is there some background on why |
I think it's pretty appropriate. Getting to muck with how code is loaded s getting to "peek under the hood" of the system. One of the goals of the |
What are the concerns? @erights? |
@matthewp |
Reflect does not provide any ability to cause I/O. If transitively frozen, it provides no access to mutable state, and so can be shared among subgraphs in the same realm that should not be able to communicate. The loader is the third example of an (existing or proposed) primordial object that does grant authority:
We do need a good way to provide standard access to authority-providing primordials such as these. In particular, I think all three of these are well motivated and should somehow become standard. But, because they provide authority they should be clearly separated from the means of providing abstractions that are safely sharable. I did not love having Loader on System, but I did not object because the separation was clear. |
Once we decide a way to provide access to the "default loader", we can clean up the current document to explicitly reference to |
Perhaps I misunderstood something. From the API doc, it looked to me like |
We need both a Loader constructor and a default loader. The docs haven't been updated to reflect (pun intended) this yet. Waiting on a decision on the names, I guess. |
If the Loader constructor is authority-free, then I have no objection to having it on Reflect. I might even prefer it. AFAICT, for it to be authority free, all four traps would need to be provided in order for it to make a Loader instance. Does that seem right? |
correct. that is why we need the separation. I will go ahead and update the doc to reflect that. For now I will use |
@erights This makes some sense to me, not only from the POLA perspective but also as a reasonable grouping: the System.global // global object
System.loader // this realm's loader
System.registry // this realm's module registry The constraints here are:
Thoughts? |
As for |
Definite +1 for going back to System and leaving Reflect for meta-object protocol stuff :) |
I like this a lot, thanks! |
@dherman maybe I'm misunderstanding you but are you suggesting getting rid of the Loader constructor? I believe we debated this a while back and it was agreed to bring it back and to put the hooks on the prototype for easier extensibility. |
Here's a previous issue where multiple instances of Loader was discussed and here's where we discussed subclassing. Would be really disappointing to roll back on this. |
@matthewp Yes, thanks for the reminder and sorry for the brain fart. @erights If I'm not mistaken, based on the previous discussion, it should be fine for the Loader constructor to live under Do you agree that is a legitimate non-privilege-escalating (unsure if I'm using the terminology right) API to live in |
@dherman I think so. Earlier I wrote:
Does it? Are we talking about the same thing? (Privilege or authority granting or providing or even bearing are good phrases for what you mean. Escalating or amplification is different.) |
Yes, all four traps have no default behavior, or more likely some of them default to pass-throughs. But the crucial point is that they provide no default access to anything from any other loader.
Thanks :) |
Ok, it seems that we are in agreement, I will go ahead and make the corresponding changes. |
What is the |
@matthewp the way I see it, all loader objects bound to the same realm should share the registry (and that includes the default loader per realm). Loader instances will not provide isolation, realms will do that, and this will prevent fetching, parsing and executing the same module multiple times in the same realm. Such as step is not in the spec just yet, nor the creation of the registry. |
Ok, in that case I will clarify that |
Exposing the registry in some way (no opinion as to how) is still probably needed to solve #17 |
@matthewp Yes, for sure. The details of the registry reflection API are blocked on the sync loading questions raised by Node, but iterating definitely has to be there. |
Solved by #65 |
|
Why is Loader in Reflect? It is a significant departure from what is currently in Reflect. Can't it be in System? |
@domenic Loader Base Class is under Reflect (more details here: #34 (comment)), while default loader instance is on System. |
I don't want to add noise to this discussion but just curious why you can't put Loader in the default loaders registry?
|
update: we will be lifting |
Summary
Decide on names for two things: the Loader constructor and the default loader instance.
Background
Originally we had global
System
andLoader
but that was when we expectedSystem.get()
to be a common use case. Once we worked out dynamic relative import, the default loader became a much more low-level API: it's meant for frameworks and loader customization logic, not for everyday use cases. So IMO giving it an attractive global name likeSystem
is inappropriate. Also, it was kind of competing withwindow
,navigator
, andprocess
as Yet Another representation of the top level application state.IMO
Reflect.Loader
is good for the constructor, but this still leaves open the question of where the default loader should live. Suggestions:Reflect
:Reflect.System
Reflect.LOADER
Reflect.Loader
:Reflect.Loader.DEFAULT
Reflect.Loader.current
Reflect.Loader.current()
Reflect.Loader
itself is both the constructor and the instanceMy preference is a
Reflect.Loader.current
getter. ALLCAPS feels more appropriate for immutable constants likeMath.PI
rather than a mutable object, and acurrent()
method feels like overkill for just accessing a singleton object. But I like the idea that it's conceptually associated with theLoader
type but it's a static singleton instance.Drawbacks
Systemjs already has named itself after System. But it's still a pretty cool name for the project, and this just gives it a more fun historical etymology. :)
The text was updated successfully, but these errors were encountered: