Re: A Result class for functions that may return errors

2016-10-18 Thread Oriol Bugzilla
Not sure if I'm missing something, but wouldn't it be trivial to code that constructor in JS? ```js class Result { constructor (type, value=true) { this[type] = value; } } function add(data) { if (data !== Object(data)) { return new Result('error', new Error('The data is not an

Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Oriol Bugzilla
Object literals (object initializers) are just a convenient way to create a new ordinary object which (initially) inherits from `Object.prototype`, and populate it with some properties. I don't think you should be able to distinguish them from similar objects not created using object

Re: Why Number(symbol) crashes?

2016-10-11 Thread Oriol Bugzilla
In my opinion it's a bit incoherent that each object-coercible type behaves differently when coercing symbols to it. Symbols can be explicitly coerced to strings, but not implicitly: ```js String(Symbol("abc")); // "Symbol(abc)" Symbol("abc") + ""; // TypeError ``` Symbols can't be coerced to

Re: JSON.stringify

2016-09-29 Thread Oriol Bugzilla
> ECMAScript, while highly used in web browsers, should really not care about > HTML constructs. That's where WHATWG and W3C come in. I suggest this type of > feature should come from one of those groups, not ECMA. That applies to escaping things like `` or `]]>`, and I agree. But as Mike

Re: Existential Operator / Null Propagation Operator

2016-09-15 Thread Oriol Bugzilla
I disagree with silently ignoring property access on null/undefined. > Early errors are nice Yes, exactly. Errors should fail early and loudly. That's why the strictness of strict mode is useful. > It's no weirder that `123.foo` not throwing. No, it's entirely different, because numbers

Re: Function composition syntax

2016-09-07 Thread Oriol Bugzilla
> Create a callable-only function that calls its left operand with the original > arguments and `this`, then calling its right operand with the result and the > same `this`. IMHO, the order seems wrong. Not sure if programming languages do it differently, but in math composition works like

Re: Bug: Reflect.ownKeys(function() {}) differs in V8 strict mode than other cases

2016-09-05 Thread Oriol Bugzilla
> So if all my code is in strict mode, and I get a non-strict code function to > shadow as Tom and I were talking about in another thread... how do I even > test for that if my code is either consistently strict or consistently > non-strict? Don't check that. The target could have other

Re: Bug: Reflect.ownKeys(function() {}) differs in V8 strict mode than other cases

2016-09-05 Thread Oriol Bugzilla
> Mozilla's approach violates ECMAScript's forbidden extensions and can't be > considered "correct" Why? The spec forbids adding "caller" or "arguments" in strict mode. I think it does not enforce adding them in sloppy mode. Chrome seems to add them only in sloppy mode, and Firefox to never

Re: Proxies and preventExtensions: how to avoid inconsistency in a membrane?

2016-09-04 Thread Oriol Bugzilla
> Could there be a Proxy.hasBeenRevoked(proxy) method? The Proxy constructor only accepts targets and handlers when they are objects and are not revoked proxies. I wonder what's the point of not allowing revoked proxies but allow revocable proxies which may be revoked later. Anyways, this

Re: Why ES6 introduced classes yet `Symbol` not to be used with `new`?

2016-08-14 Thread Oriol Bugzilla
Probably, because symbols are primitive values, and constructors only create and initialize objects. So you are supposed to call it as a function instead of as a a constructor. That said, it might make sense for `new Symbol()` to return a symbol object. But instead, you can use

RE: Array.prototype.includesAll

2016-06-14 Thread Oriol Bugzilla
> There are no items in `[]` so that doesn't seem like a true statement to me. It's true by [Vacuous_truth](https://en.wikipedia.org/wiki/Vacuous_truth). > So, at least consistency pulls towards `false`. You are misunderstanding what `includes` does when there is no argument. ```js

RE: Array.prototype.includesAll

2016-06-14 Thread Oriol Bugzilla
What's the point of using `reduce` instead of `every`? ```js Array.prototype.includesAll = function (...args) { return args.every(item => this.includes(item)); } ``` I disagree with this test ```js expect([2, 3].includesAll()).toBe(false) ``` The array `[2,3]` includes all items in `[]`. So

RE: Array.prototype.includes with multiple arguments

2016-06-10 Thread Oriol Bugzilla
Array.prototype.includes uses the second argument as the starting index. Therefore, these calls would be identical, but you want them to behave differently: ``` ["a"].includes("a", 0); // true -- "a" can be found at position 0 ["a"].includes(...["a", 0]); // false -- 0 can't be found in the

RE: Reflect.create()

2016-05-26 Thread Oriol Bugzilla
I agree with Bergi. > Brendan Eich and think he understood that fairly I can't see that. He says things like "what's to propose?", "what is declare? I don't think core language needs to grow", "What does this have to do with promises?", "I don't see the point" and "It's not making sense,

RE: How about a "named true" and a "named true property"

2016-05-26 Thread Oriol Bugzilla
As Isiah Meadows said, you can just use variables. ``` var removeNode = true; control.dispose(removeNode); ``` ``` var silent = true, disableValidation = true, destroyOldValue = false; model.set('foo', newValue, {silent, disableValidation, destroyOldValue});``` From:

RE: Proposal: Switch position of delay and callback in signature of `setTimeout()`

2016-04-25 Thread Oriol Bugzilla
`setTimeout` is not part of ECMAScript. You should suggest this to WHATWG instead. - Oriol From: m...@adriansieber.com Date: Mon, 25 Apr 2016 17:35:50 + Subject: Proposal: Switch position of delay and callback in signature of `setTimeout()` To: es-discuss@mozilla.org Everytime I

RE: Extending Object

2016-04-23 Thread Oriol Bugzilla
They are no necessary the same: ```js var _Object = window.Object, Object = function() {}; class Foo1 { constructor() {} } class Foo2 extends Object { constructor() { super(); } } _Object.getPrototypeOf(Foo1.prototype); // _Object.prototype _Object.getPrototypeOf(Foo2.prototype); //

Take let variable out of temporal dead zone

2016-04-15 Thread Oriol Bugzilla
Consider this code: ```html let {foo} = null; // TypeError // Here I want to assign some some value to foo ``` The first script attempts to let-declare `foo` via a destructuring assignment. However, `null` can't be destructured, so the assignment throws a TypeError. Some alternatives which