Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(277)

Issue 7447045: Implement 'return' in generators. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 3 months ago by usrbincc
Modified:
13 years, 3 months ago
Reviewers:
peterhal, arv
CC:
traceur-compiler-reviews_googlegroups.com
Base URL:
https://code.google.com/p/traceur-compiler/@master
Visibility:
Public.

Description

Implement 'return' in generators. The ability to get and set the GeneratorReturn constructor and the StopIteration object should allow for easier interop with Q and TaskJS. BUG=None TEST=test/feature/Yield/GeneratorReturn.js

Patch Set 1 #

Total comments: 13

Patch Set 2 : Fix GeneratorReturn.toString, excess YieldFinder, isUndefined(), indentation. #

Total comments: 1

Patch Set 3 : Identical to patch set 2 with semantics/util.js, etc split out. #

Patch Set 4 : Oops. Added missing brace. #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+271 lines, -43 lines) Patch
M src/codegeneration/GeneratorTransformPass.js View 1 4 chunks +14 lines, -6 lines 0 comments Download
M src/codegeneration/generator/GeneratorTransformer.js View 1 8 chunks +21 lines, -5 lines 1 comment Download
A src/codegeneration/generator/ReturnState.js View 1 1 chunk +59 lines, -0 lines 0 comments Download
M src/codegeneration/generator/YieldState.js View 2 chunks +2 lines, -5 lines 0 comments Download
M src/runtime/runtime.js View 1 2 3 2 chunks +57 lines, -27 lines 0 comments Download
M src/syntax/PredefinedName.js View 1 chunk +1 line, -0 lines 0 comments Download
A test/feature/Yield/GeneratorReturn.js View 1 1 chunk +117 lines, -0 lines 0 comments Download

Messages

Total messages: 15
usrbincc
The pre-patches actually shouldn't affect this patch, so I've left them out here. Meant to ...
13 years, 3 months ago (2013-03-01 19:16:12 UTC) #1
arv
I'm not fully sure how this works. Why do we need a GeneratorReturnLocal? Your sample ...
13 years, 3 months ago (2013-03-05 17:27:04 UTC) #2
usrbincc
Read over this and honestly can't tell if this will come across as gibberish or ...
13 years, 3 months ago (2013-03-06 13:03:17 UTC) #3
usrbincc
Split the patches for cleaner history. See Move util functions from DefaultParametersTransformer.js to src/semantics/util.js https://codereview.appspot.com/7509043/ ...
13 years, 3 months ago (2013-03-06 16:18:24 UTC) #4
arv
Inline On Wed, Mar 6, 2013 at 8:03 AM, <usrbincc@yahoo.com> wrote: > Read over this ...
13 years, 3 months ago (2013-03-06 16:22:06 UTC) #5
usrbincc
Here is the relevant part of harmony:generators. Note especially the object R, and how they ...
13 years, 3 months ago (2013-03-07 15:01:59 UTC) #6
arv
On Thu, Mar 7, 2013 at 10:01 AM, <usrbincc@yahoo.com> wrote: > Here is the relevant ...
13 years, 3 months ago (2013-03-07 15:48:13 UTC) #7
arv
LGTM https://codereview.appspot.com/7447045/diff/21001/src/codegeneration/generator/GeneratorTransformer.js File src/codegeneration/generator/GeneratorTransformer.js (right): https://codereview.appspot.com/7447045/diff/21001/src/codegeneration/generator/GeneratorTransformer.js#newcode284 src/codegeneration/generator/GeneratorTransformer.js:284: throw new traceur.runtime.GeneratorReturn(${$YIELD_RETURN}); OK for now but I ...
13 years, 3 months ago (2013-03-07 16:21:59 UTC) #8
arv
Committed as f4991362e3b2ddca4fc4be1eacb98b852b20a02b
13 years, 3 months ago (2013-03-07 16:25:40 UTC) #9
usrbincc
> Mozilla is shipping for-of That is a surprise. I haven't updated my local ionmonkey ...
13 years, 3 months ago (2013-03-07 16:41:06 UTC) #10
arv
> > Oops; forgot about return values. Ironic, considering this > patch. I kind of ...
13 years, 3 months ago (2013-03-07 19:37:11 UTC) #11
peterhal
C# doesn't support return in generators. On Thu, Mar 7, 2013 at 11:36 AM, Erik ...
13 years, 3 months ago (2013-03-07 20:03:58 UTC) #12
usrbincc
> Yesterday there was some epic twitter fights related to > this (all between Moz ...
13 years, 3 months ago (2013-03-08 17:01:51 UTC) #13
peterhal
On 2013/03/08 17:01:51, usrbincc wrote: > > C# doesn't support return in generators. > > ...
13 years, 3 months ago (2013-03-08 18:58:20 UTC) #14
usrbincc
13 years, 3 months ago (2013-03-08 21:26:43 UTC) #15
Message was sent while issue was closed.
> Somehow I was under the impression that python allowed
> returning values from generators but I can't find any
> evidence of that. I agree that returning values from
> generators is overly complex.

While looking through

  comparing different iteration protocols
  https://gist.github.com/dherman/5101199

I stumbled upon

  PEP 380 -- Syntax for Delegating to a Subgenerator
  http://www.python.org/dev/peps/pep-0380/

and it looks like return values for generators have "Final"
status, and are slated for Python 3.3 -- the 'python3'
executable I checked with was Python 3.2.3 . Oh well.

  There was this other language that had lots of features,
  and you weren't supposed to pay for the features you
  didn't use, but someone always used one of them, so you
  did end up paying, at least in mental real estate.

  /rant

As with any language feature, there are probably good ways
to use generator return values. At this point, I just hope I
don't have to deal with too much code of the other variety.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b