Are the values of objects the references to them?

Michael Dyck jmdyck at
Sat Aug 26 20:26:11 UTC 2017

On 2017-08-26 05:40 AM, Danny Niu wrote:
> Hi all, I've been struggling finding information on this, so let me open
> by asking the following question:
> Q1: If primitive types are passed by value and objects by reference when
> calling function, where is this characteristic of objects mentioned in
> the standard?

Objects aren't "passed by reference" according to the original/usual sense
of that term.

> People from seems adamant that
> ES is a pass-by-value language, so I assumed the value of objects are
> their individuality.

The top two answers there both say (more or less) it's pass-by-value, and
for objects, the 'value' is a reference to the object.

So you might wonder why objects are special in this regard. But they aren't:
if you like, you can imagine everything being passed by value, where the
'value' is a reference to the thing.

> Q2: What's the rationale if any, to not explicitly require that objects
> be viewed as reference when passed as arguments to functions and assigned
> to variables.

One reason might be to avoid confusion with the Reference type. Another
reason might be to avoid making a distinction that the spec will never (or
rarely) use.

When you pass a value to a function-parameter or assign a value to a
variable, you are (in spec terms, more or less) binding that value to an
identifier name, i.e., creating an association between the name and the value.

Given that terminology, I don't think it helps to add "reference" to the
description. It's enough to understand that a value can participate in
multiple bindings/associations at the same time. But you're free to imagine
references being involved in the implementation.


More information about the es-discuss mailing list