-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Looking through built-in functions defined as generators, some of them use Yield()
while other use GeneratorYield()
. There doesn't seem to be a clear rule about which one to use when. For example:
- 7 uses of
Yield()
, out of which two are foryield;
andyield expr;
- 9 uses of
GeneratorYield()
, out of which one is inYield()
and three inyield* expr
AsyncGeneratorYield()
is only used inYield()
andyield* expr
- https://tc39.es/ecma262/#sec-generatorstart introduces 4 more usages of
Yield()
The difference between Yield()
and GeneratorYield()
/AsyncGeneratorYield()
is that Yield()
first checks if we are in a sync or async generator, and then dispatches to the right AO.
It'd be great if there was a consistent guideline around it. Either:
- Always use
Yield()
.GeneratorYield()
/AsyncGeneratorYield()
are only called byYield()
itself. - Always use the correct one between
GeneratorYield()
/AsyncGeneratorYield()
, whenever it's know whether we are in a sync or async built-in generator.Yield()
would only be used to implement the actualyield
syntax.
Metadata
Metadata
Assignees
Labels
No labels