Re: Proposal: then operator for easier promise manipulation

2018-03-04 Thread Bryant Petersen
Thank you for the questions. > How do you determine how far up in the expression tree you go? I think this is a good question. When I go through various expressions, it seems obvious to me given the intent of the operator where to draw the line. In cases like `let x = ...`, `function() { ... }`,

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Peter Jaszkowiak
This operator doesn't make any sense to me. It has to know not only the immediate expression to its left and/or right like normal operators. It's **absolutely** not a unary operator, as it has to have information about every outer operator. It's almost an inverted operator in that sense. If we're

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Bryant Petersen
An expression which contains a `then` operator is not run synchronously. It does not run until its `then` expressions are resolved. It is like the body of a callback function, since the statements following it will most likely run before it does. The way I would implement this is by having certain

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Tab Atkins Jr.
On Sat, Mar 3, 2018 at 1:04 AM, Bryant Petersen wrote: > The purpose of `await` is to allow synchronous execution within an > async function. > > The purpose of `then` is to make it easier to manipulate the promises > as if they were normal values. It is much closer to > `Promise.prototype.then` t

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Bryant Petersen
The purpose of `await` is to allow synchronous execution within an async function. The purpose of `then` is to make it easier to manipulate the promises as if they were normal values. It is much closer to `Promise.prototype.then` than to `await`, since it does not prevent the statements following

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Peter Jaszkowiak
Why not just use async/await then? Seems like if you were to replace `then` with `await` in your top example it would work exactly as you want (as long as it's in an async function). On Sat, Mar 3, 2018 at 1:06 AM, Bryant Petersen wrote: > I've put the details here: https://github.com/bwpetersen

Proposal: then operator for easier promise manipulation

2018-03-03 Thread Bryant Petersen
I've put the details here: https://github.com/bwpetersen/proposal-then-operator The basic idea is that the `then` operator would allow you to manipulate a promise as if it were its resolved value. Expressions containing `then` become similar to an `onFulfillment` handler. Here is an example: ```