Skip to content

mutable System.loader #72

Open
Open
@dherman

Description

@dherman

To support not only subclassability (see #35) but the ability to use a custom subclass as the built-in loader, should we allow System.loader (according to the discussion in #34 this seems to be the best name for the default system loader to live in) to be mutated?

The reason to allow this is that it's more expressive: if you have custom loader logic defined in a subclass, you can't use that simply by modifying the hooks of System.loader; you need to replace it with an instance of that subclass.

There are a couple of subtleties, however:

  • It's not likely to be possible to replace the registry of one loader with another (even when we expose the registry as an object, its methods have to be bound to its owning loader in order to consult the hooks). Instead, replacing System.loader would require you also to populate the new loader's registry with any entries you want to share from the old one. (At a minimum this can be done by iterating over the old registry (see Iterating over the registry #17) and copying the entries in. Alternatively it should be possible to define subclasses with "chaining" logic that allows some lookups to delegate to another loader.)
  • Implementors will probably prefer that none of the HTML semantics requires directly triggering a property get. I don't have a super crisp explanation for why that is, but I suspect there could be security worries when we do things like that, or possibly performance issues. However, this seems pretty easily managed as long as we define all the API's in terms of getter/setters or methods that consult internal properties. So for example the %System% object would have a [[Loader]] property, for example, with System.loader being a getter/setter pair.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions