Dreaming the future of software; Project Editor ECMAScript 2015; Reformed Smalltalker JavaScript historian dl.acm.org/doi/abs/10.114@allenwb@mastodon.social

Sherwood Oregon USA
16/16 So that’s the story of Symbol.toPrimitive. If you look at the other predefined symbols you will see that most of them correspond to various rarely used magic hooks that allow self-hosting without complicating the set of Proxy traps.
1
4
15/ So I proposed we eliminate the [[DefaultValue]] internal method (and Proxy trap) and replace it with a regular (property value) method with a Symbol property key. This allows the self-hosting of Date without complicating the MOP/Proxy interface.
1
1
14/ The first versions of the Proxy design included defaultValue as a trap because it was an “internal method” thanks to ES1. We wanted to minimize the number of Proxy traps. [[DetaultValue]] was only used by ToPrimitive and only Date had special [[DefaultValue]] behavior.
1
13/ The Proxy traps correspond to the MOP, the meta object hooks used by engines to perform object “magic”. To accomplish the ES6 self-hosting goal all such magic had be hookable via Proxy traps or some other JS accessible mechanism.
1
1
12/ A goal of ES6 was to allow the implementation of built-in and host objects to be “self-hosted” using JS code. For this to be possible, we needed to eliminate all “magic” that could only be accomplished within an engine. Proxy objects is the main solution to that problem.
1
1
11/ So Date was the culprit! Date default coerced to a string. All other standards objects default coerced to a number.
1
3
10/ The single ES1 definition of [[DefaultValue]] says: When the [[DefaultValue]] method of O is called with no hint, then it behaves as if the hint were Number,unless O is a Date object (see section 15.9), in which case it behaves as if the hint were String.
1
3
9/ ( In theory, [[DefaultValue]] is not restricted to just choosing the order of invoking valueOf/toString. A primitive value returned from [[DefaultValue]] is used as the result of ToPrimitive. How [[DefaultValue]] determines its result is completely up it.)
1
2
8/ The way ES1 specified that each kind of object could make this choice is by stating that at the engine layer an object must provide a [[DefaultValue]] internal method. Internal methods are the ES “meta object protocol" (MOP) and in ES6+ correspond to proxy traps.
1
2
7/ The ES1 spec. allowed different “kinds” of objects to decide on this order. But “kinds” in this case only means different built-in or host provided classes of objects. All user defined objects treat “no hint” as “hint number”.
1
1
6/ But in some parts of the specification where ToPrimitive is used there is no preference for a number or string. In those cases no hint is given. In that case which method, valueOf or toString should ToPrimitive try to invoke first?
1
2
5/ If the hint is number, ToPrimitive invokes valueOf 1st but if its result is an object then toString is invoked. If neither returns a primitive value an error is thrown. If the hint is string, the order of invoking valueOf and toString is reversed.
1
2
4/ ToPrimitive is used at various places in the spec where an object needs to be coerced to a primitive value. In some cases a “hint” is provided as to whether a string or number is the preferred result.
1
1
3/ The normal way an object is converted to a primitive is by invoking the object's valueOf or toString method. valueOf normally returns a number and toString a string.
1
1
2/ ToPrimitive is an specification device in the ECMAScript spec that is used to define how objects get converted to primitive values (e.g., strings, numbers) It has existed since the ES1 spec but its formulation (but not its normal results) has changed over time.
1
1
I think Marco is mostly right in this thread and he isn't the only person to have backed away because of a values conflict. But I don't think most individuals involved are directly motivated by $'s. But many do represent and prioritize the values of big tech culture
Replying to @polotek
I remember the realization that this process had nothing to do with enabling more people to learn JavaScript. It was mostly about giving the language more capabilities, and enabling the inevitable rise in the *business* of tech. Turns out programming languages are big business.
2
5
17
But an alternative way to think of null is as an unique immutable object with no properties. In that case, missing property access on null should have worked just like any other objects. null.anything or null[whatever] should have evaluated to undefined 2/2
3
1
11
If I could change JS 1.0 design: null was intended to mean “no object value” (or Java null value) and “undefined” (originally a value without a name) meant an uninitialized variable or missing property. Hence (in JS 1.1), typeof null == “object" 1/
One of the most baffling *recent* inconsistencies in JS: var x = null; var y = { ...x }; // empty destructuring, no error var z = [ ...x ]; // error! This was discussed at length, and yet they still justified the inconsistency and did it on purpose. SMH.
2
4
14
According to the original source code: slice is directly inspired by the Python slice sequence operation. splice, push, pop, shift, unshift were directly copied from Perl. The confusing similarity of slice/splice names probably due to merging unrelated vocabularies.
Flimsy, but this is how I distinguish Array methods: – slice vs. splice: slice is the more common word, used more commonly and (more usefully) non-destructive. – shift vs. pop: Perl uses shift() to process function arguments; it accesses arg #0 first. JS “stacks” grow at the end.
6
9
Allen Wirfs-Brock retweeted
One of the most baffling *recent* inconsistencies in JS: var x = null; var y = { ...x }; // empty destructuring, no error var z = [ ...x ]; // error! This was discussed at length, and yet they still justified the inconsistency and did it on purpose. SMH.
21
90
352