Global as a module

Since the introduction of ES modules, many have considered (maybe just me many times) marshalling their globals through modules for various purposes.

This comes out of the need to safely do things about globals without ever affecting, or becoming affected by the actual globals (ie subsequently where effects are not preferred).

The last remark, imho aligns nicely with our principles when we endow a container of some sort.

A thought that I’d like to propose here is to consider global endowments being just another one of the attenuated modules, ie of the one explicit specifier that cannot be remapped.

This would complicate the mutability of endowed primitives, ie if such mutability is an intended goal here, likely not.

Streamlining everything together:

  1. Minimizes the cognitive burden when reasoning about endowments.
  2. Minimizes the moving parts, hence points of potential failure.

Thoughts?

I’m still not sure about this. We probably need to come up with a concrete example of how this would benefit confinement or strong encapsulation, so that other people can understand what this idea gives them.

Thanks,
Michael.

1 Like