tc39 / proposal-get-intrinsic

EcmaScript language proposal for a way to get intrinsics.
https://tc39.github.io/proposal-get-intrinsic/
MIT License
32 stars 4 forks source link

All intrinsics, or just hidden ones? #21

Open ljharb opened 1 year ago

ljharb commented 1 year ago

(if i'm recalling correctly) @syg pointed out that there might be memory issues with holding on to every intrinsic, and asked if this proposal could include only hidden intrinsics.

The upside: we could explicitly list all the hidden intrinsics in the spec, and implementations wouldn't have to keep track of every intrinsic. Additionally, https://npmjs.com/get-intrinsic and SES and test262 would all be able to drop their custom hardcoded ways to reach hidden intrinsics, since they're all now discoverable.

The downside: both https://npmjs.com/get-intrinsic and SES would have to retain their "walk the graph" approach in order to locate all intrinsics.

I strongly prefer that this be all intrinsics - "just hidden" would certainly achieve the SES need of ensuring that hidden intrinsics are no longer undiscoverable, but it wouldn't achieve the ergonomic and API requirements that motivated the proposal in the first place.

mhofman commented 5 months ago

An orthogonal question is whether to list all intrinsics or just reachable ones. There are actually 2 subsets in this subtle distinction:

I don't believe spec fiction intrinsics should ever be exposed through any means, and I would strongly prefer that it would be permitted to skip otherwise unreachable intrinsics.

(There is also an argument to be made the better term according to the glossary would be primordial instead of intrinsic.)

ljharb commented 5 months ago

Absolutely fictional intrinsics would never be included in this list.

Additionally, any intrinsic that isn't otherwise reachable through this proposal would certainly not be included - if SAB is not otherwise exposed in JS as a global, then it wouldn't be exposed here.