Skip to content
This repository has been archived by the owner on Feb 3, 2019. It is now read-only.

No need for Symbol to be visible on Module Namespace #7

Open
bmeck opened this issue May 22, 2018 · 6 comments
Open

No need for Symbol to be visible on Module Namespace #7

bmeck opened this issue May 22, 2018 · 6 comments
Milestone

Comments

@bmeck
Copy link
Member

bmeck commented May 22, 2018

A variety of Symbols can be used to change behaviors but are not always exposed / used for exotic objects:

class X {};
Object.setPrototypeOf(X, null);

// undefined, true
console.log(X[Symbol.hasInstance], new X() instanceof X);
@ljharb
Copy link
Member

ljharb commented May 22, 2018

The entire reason for this proposal is because the committee did not want magic behavior for Namespace objects; they wanted a general-purpose solution.

@jdalton
Copy link
Member

jdalton commented May 22, 2018

The entire reason for this proposal is because the committee did not want magic behavior for Namespace objects; they wanted a general-purpose solution.

I don't think these are mutually exclusive. Taking Bradley's example where functions have some unexposed behavior there's also user-facing parts like Symbol.hasInstance and even a proxy trap. So while parts can be unexposed other parts can be exposed.

@devsnek
Copy link
Member

devsnek commented May 22, 2018

what people seemed to want was a consistent way to be able to explain why object X isn't behaving like object Y. the most obvious way to go about that with the current mechanics we have available seemed to me to be a symbol.

@jdalton
Copy link
Member

jdalton commented May 22, 2018

I don't see it specified in this proposal but is the idea that for namespace objects it would be non-enumerable, non-configurable, non-writable like the namespace @@toStringTag?

@devsnek
Copy link
Member

devsnek commented May 22, 2018

@jdalton yeah; its not in the readme but i put it in spec.html: https://gus.host/proposal-symbol-thenable/#sec-@@thenable

@ljharb
Copy link
Member

ljharb commented May 22, 2018

That's more of a stage 2 concern, but yes, I would imagine so - module namespace objects are meant to be fully immutable.

(edit: sorry, closed by accident)

@ljharb ljharb closed this as completed May 22, 2018
@ljharb ljharb reopened this May 22, 2018
@devsnek devsnek added this to the Stage 2 milestone May 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants