Skip to content

Commit

Permalink
Docs: Fix the description of PrivateName in DETAILS.md
Browse files Browse the repository at this point in the history
  • Loading branch information
littledan committed Jul 12, 2018
1 parent 4c6a14e commit 1d5c5c9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions DETAILS.md
Expand Up @@ -55,10 +55,10 @@ However, in normal usage which does not reference these runtime metaprogramming-

Private state is not keyed on property keys--Strings or Symbols--but instead on Private Names. Literal references like `#x` are lexically bound to a Private Name which is textually present in the definition of a class, but decorators can create new, anonymous private fields by imperatively creating Private Names and adding them to the List of fields defined for the class.

To create and use private names, a new function `PrivateName` is created:
- `new PrivateName(description)` creates a new Private Name object, which cannot be used as a property key.
- `PrivateName.prototype.get(object)` gets the private field or method value from the object, or invokes a getter, or throws a *ReferenceError* if it is not present.
- `PrivateName.prototype.set(object)` sets the private field value in the object, or invokes a setter, or throws a *ReferenceError* if it is not present or if it is a private method.
There is no direct interface for creating a PrivateName, but they are passed into decorators in as a `key`, and are objects with the following properties:
- *privateName*.`get`(*object*) gets the private field or method value from the object, or invokes a getter, or throws a *ReferenceError* if it is not present.
- *privateName*.`get`(*object*, *value*) sets the private field value in the object, or invokes a setter, or throws a *ReferenceError* if it is not present or if it is a private method.
- *privateName*.`description` is a string which represents the PrivateName; for example, it would be `x` for a PrivateName which is textually `#x`.

The interface for adding a private field to an object is to add a field descriptor using a decorator. A particular private name may be used just once, to define a single field. With this pattern, each private field is added by exactly one class.

Expand Down

0 comments on commit 1d5c5c9

Please sign in to comment.