W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2014

RE: Promise<void> or Promise<undefined>?, was Re: RfC: pre-LC version of Screen Orientation; deadline August 18

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Thu, 14 Aug 2014 20:44:04 +0000
To: Marcos Caceres <marcos@marcosc.com>, public-script-coord <public-script-coord@w3.org>
CC: Dominique Hazael-Massieux <dom@w3.org>, Mounir Lamouri <mounir@lamouri.fr>
Message-ID: <1408049052992.82682@domenicdenicola.com>
From: Marcos Caceres <marcos@marcosc.com>

> It was raised elsewhere that maybe this should be `Promise<void>` instead? What would be more idiomatic?

For JS? undefined. For WebIDL? void.

> Using void seems to make more sense then passing `undefined` to the resolver - as the arguments.length would be 0 instead of 1 (undefined).

I don't think it makes any difference. From the engine's perspective, resolve() and resolve(undefined) are indistinguishable. arguments.length of the onFulfilled callback is unaffected:

Promise.resolve(undefined).then(function () {
  assert(arguments.length === 0);

Promise.resolve().then(function (value) {
  assert(arguments.length === 1);
Received on Thursday, 14 August 2014 20:44:49 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:22 UTC