There is a spec reference type.  It was initially there for host objects,
and IIRC, most were happy to see it go.



http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf

8.7 The Reference Type
The internal Reference type is not a language data type.

It is defined by this specification purely for expository purposes. An
implementation of ECMAScript must behave as if it produced and operated
upon references in the manner described here. However, a value of type
Reference is used only as an intermediate result of expression evaluation
and cannot be stored as the value of a variable or property.

The Reference type is used to explain the behaviour of such operators as
delete, typeof, and the assignment operators. For example, the left-hand
operand of an assignment is expected to produce a reference. The behaviour
of assignment could, instead, be explained entirely in terms of a case
analysis on the syntactic form of the left-hand operand of an assignment
operator, *but for one difficulty: function calls are permitted to return
references.* *This possibility is admitted purely for the sake of host
objects.* No builtin ECMAScript function defined by this specification
returns a reference and there is no provision for a user-defined function
to return a reference. (Another reason not to use a syntactic case analysis
is that it would be lengthy and awkward, affecting many parts of the
specification.)

Another use of the Reference type is to explain the determination of the
this value for a function call. A Reference is a reference to a property of
an object.

A Reference consists of two components, the base object and the property
name.

The following abstract operations are used in this specification to access
the components of references:
• GetBase(V). Returns the base object component of the reference V.
• GetPropertyName(V). Returns the property name component of the reference
V.

The following abstract operations are used in this specification to operate
on references:



http://www.ecma-international.org/ecma-262/#sec-reference-specification-type
is the much reduced equivalent in the current draft.
6.2.4The Reference Specification Type


Trying to expose the reference specification type as an actual user
manipulable type would have a lot of consequences, and would not
actually address the local variable use case.


If your use case can be satisfied by objects like some syntactic sugar like
    { get content() { return x }, set content(v) { return x = v } }
then you might find it easier asking for that instead of a new type.




On Mon, Mar 19, 2018 at 3:47 PM, Sebastian Malton <[email protected]>
wrote:

> Proposal:
> Add a new variable-esk type called pointer which acts sort of like a
> reference to the data which it has been assigned to but modifies also the
> original reference when modified.
>
> Justification:
> When working with objects in particular it is often useful for satiny
> reasons to use local variables (mostly const's) as a shorthand reference
> both for compactness and also so that you don't have to type out the entire
> path every type. This would allow for non - objects but also overwriting
> objects if wanted but still have this freedom and convenience.
>
> Method:
> Add a new notation
>
> ```
> let:prt name = obj.field.name.fullname;
> ```
>
> Here if `name` is updated or if `obj.field.name.fullname` is updated so is
> the other.
>
> Sebastian Malton
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to