Is the hash symbol the best? It already is used within classes to mean <i>private</i>. Syntactically for the machine parser, I assume it will work just fine for these other things. But semantically for my human brain, it is mildly incongruous. If for no reason but elegance and developer delight, I ask for a reconsideration of other punctuation.
I've always thought it was interesting to see the parallels of PHPs growth and JSs. Both seem to add a lot of popular (at the time) features. Neither can purge old APIs or "break the web".
This is the number one feature I look for in a language now. It’s hard to describe why value semantics are useful when thinking about a language as it exists today, since the language influences what we think is possible. But having records and tuples like this changes the way you write code.<p>The biggest example is, you don’t have to think in terms of references anymore. Again it’s hard to explain how much were forced to think about references and specific locations that data happens to live at, but that thinking is pervasive in how we write code (if you’re using a language like JS, which most popular languages are like).<p>Value semantics means you can stop thinking about data-as-a-location or data-as-a-reference and finally start thinking about data-as-data. If two records have the same values, they are the same. This means you don’t need to know anything about where data came from, you can construct matching data and say “are these things equal?” And they will be. This inherently reduces coupling and complexity.
So from reading this it sounds like what's being asked for essentially syntactic sugar for Object.freeze(), and the function Record(obj) would be doing something along the lines of<p><pre><code> function Record(obj)
let result = {};
for (let [key, value] of obj) {
switch (typeof value) { case "function": case "object": throw ...; }
result[key] = obj;
}
Object.freeze(result);
return result;
}
</code></pre>
Or similar.<p>Now obviously have typeof return a new type is exciting, and of questionable value, but having a "only immutable values can be in fields" guarantee could be useful.<p>That said, overloading # is not something I think is great, and the semantics need to be tightened up (fields in prototype chain, etc, what is the prototype of the resulting record/tuple object).
The Value of Values with Rich Hickey<p><a href="https://youtu.be/-6BsiVyC1kM" rel="nofollow">https://youtu.be/-6BsiVyC1kM</a>