Brendan Eich (2013-07-22T22:25:21.000Z)
domenic at domenicdenicola.com (2013-07-24T00:17:58.809Z)
Allen Wirfs-Brock wrote: > Except that: > ```js > new Boolean(false) === false //false similarly String and Number > Boolean(false) === false //true similarly String and Number > ``` > > so the difference between wrappers and primitive values is observable. Sure, legacy crap we must not copy into new types. Right? > It isn't observable whether there is a single or multiple heap element for each logically === equivalent primitive value/ I explicitly addressed truthy ToObject later. Did you miss it? Boolean is a terrible precedent for value objects, which must include 0 when numeric (int64, uint64, bignum, decimal, rational, etc.). > I think the truthiness of 'new Boolean(false)' is a one-off special case that we shouldn't worry about as a precedent. I don't believe there are equivalent issues with String or Number. Sure: "" is falsy but new String("") is truthy; 0 and NaN are falsy but new Number(0), e.g., is truthy. Ok, so a three-off special case-set we should not imitate with value objects in general. Right? > This would be a new idiom, and one that wouldn't necessarily apply to non-structured objects. This is a refactoring hazard if someone starts with a normal object and decides to re-implement as a struct-based object. If you are arguing that constructors must not do something other than construct when called, let's have that discussion separately. It's a general fly in your refactoring ointment -- and has been forever in JS. > Since this is a new idiom, other new idioms could be considered. For example: > > ```js > new T(x) //create a mutable instance: > T.value(x) //create an immutable instance > ``` > > bikesheding starts here... I thought about such things but it's not only a matter of bikeshedding. Usability comes first and is not all about aeshetics. Say we add int64. To convert to it, must I call ```js int64.value(x) ``` and not ```js int64(x) ``` merely to preserve some object-idiom idiocy that no one wants for int64, namely: ```js new int64(x) // throws, does not make a mutable object ``` ?