Talk:Value type and reference type

Does JavaScript not have value types?
According to JavaScript: The Definitive Guide (4th edition): "The types can be divided into two groups: primitive types and reference types. Numbers, boolean values, and the null and undefined types are primitive. Objects, arrays, and functions are reference types." … "Strings are an unusual case." — Preceding unsigned comment added by 2001:464F:23F3:0:D16E:6733:6BA1:273A (talk) 19:02, 8 December 2019 (UTC)

Article seems to conflate a few different things
This article seems to conflate a few different concepts:


 * 1) Many languages support a special kind of value that points to an abstract memory location. Examples include "pointers" in C and C++ (where &i is a pointer to i &mdash; if i has type int, then &i has type int *) and "references" in Perl (where \$i is a reference to $i).
 * 2) Many languages support a kind of variable that's an alias for an existing entity. Usually this is only supported for function parameters ("call by reference"), but in a few languages it's supported more generally; for example, in C++, <tt>int & i = j</tt> declares <tt>i</tt> as a "reference" to <tt>j</tt>, so any reads or writes involving <tt>i</tt> are implicitly forwarded to <tt>j</tt>. (Conceptually, we can imagine <tt>i</tt> as syntactic sugar for dereferencing a pointer <tt>i_ptr</tt> that points to <tt>j</tt>.)
 * 3) In some languages, some kinds of entities are always implicitly accessed via a pointer/reference. An example is Java, where this is true of objects: <tt>Object obj1 = obj2</tt> doesn't create a new object, but rather, it makes <tt>obj1</tt> refer to the same object that <tt>obj2</tt> currently refers to. This is different from C++ references in that either <tt>obj1</tt> or <tt>obj2</tt> can subsequently be changed to refer to a different object. Other languages with the same approach include C#, Python, and JavaScript.

These concepts all use the term "reference" in closely related ways (and sometimes the lines between them are a bit blurry); but I think that the terminology of "value types" vs. "reference types" specifically refers to concept #3. The idea is that, in languages like Java, there are some types of entities (non-object types) that can be accessed directly, and other types (object types) that can only be accessed via references/pointers.

So, I'd like to rework this article to specifically focus on concept #3. The article would still discuss #1 and #2, but only with an eye toward elucidating #3 and showing how it relates to concepts in other languages (or even in the same languages: C# has all three of these).

Would anyone object to my doing that? (Normally I'd just "be bold", but in this case it would mean removing a significant proportion of the current content of the article, so I figured it's worth discussing beforehand.)

—Ruakh <i >TALK</i > 17:42, 29 August 2023 (UTC)


 * Addendum: I've now made those changes. —Ruakh <i >TALK</i > 23:17, 1 September 2023 (UTC)