-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using 'yield' automatically turns functions into generators #3240
Merged
Merged
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f51cbd7
removed 'yield' from the reserved keywords
alubbe dafc7bd
added 'yield' to the unary keywords
alubbe 9941050
using 'yield' automatically turns functions into generators
alubbe f11ca98
added a test for generators
alubbe 7906a2b
removed yield from the reserved words
alubbe d712a6c
npm run-script test-harmony executes generator tests
alubbe 74a92db
improved readability of generator test
alubbe 9d29a83
entire generator test file is now ignored if generators are not avail…
alubbe 85c7fff
improved readability of cakefile generator check
alubbe f4b850d
further improved readability of cakefile generator check
alubbe c02a403
fixed misspelling in Cakefile
alubbe e100020
Merge github.com:jashkenas/coffee-script
alubbe 56b04a5
first attempt at using '->*" and '=>*' for generators
alubbe dab4ae9
'->*' and '=>*' now produce generators
alubbe 25b1eee
first attempt at including 'yield*'
alubbe 64e78a2
updated lexer to allow 'yield*'
alubbe 1e377ed
'yield*' now works as expected
alubbe f375394
Merge https://github.com/jashkenas/coffee-script
alubbe 7590066
Merge remote-tracking branch 'A/master'
alubbe 565d78f
removed support for '->*" and '=>*'
alubbe c725566
added 'yield from'
alubbe 437b9ed
added 'yield return'
alubbe 781ea22
always wrap 'yield' in () to allow composability with all other opera…
alubbe efca286
added tests for yield, yield from, yield return and yield in if state…
alubbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generators | ||
# ----------------- | ||
|
||
# * Generator Definition | ||
|
||
# Using the keyword yield should not cause a syntax error. | ||
-> yield 0 | ||
|
||
test "Generator Definition", -> | ||
x = -> | ||
yield 0 | ||
yield 1 | ||
yield 2 | ||
y = x() | ||
z = y.next() | ||
eq z.value, 0 | ||
eq z.done, false | ||
z = y.next() | ||
eq z.value, 1 | ||
eq z.done, false | ||
z = y.next() | ||
eq z.value, 2 | ||
eq z.done, false | ||
z = y.next() | ||
eq z.value, undefined | ||
eq z.done, true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another opinion on the readability of this bit of code: wouldn't this be the same as:
?
I find both of them more straightforward to read. But, i usually prefer single assignment variables if possible, so it probably is a very biased opinion =P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I'd expect
break
after this line. IsexecArgv.some
guaranteed to be defined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK if the compiler is supposed to run on old IE (if it is: does someone test that?), but, in case it is, there seems to be a helper for that available.