Created
May 8, 2011 16:15
-
-
Save DmitrySoshnikov/961469 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$coroutine = (func) -> -> | |
gen = func(arguments...) | |
gen.next() | |
gen | |
grep = $coroutine (pattern) -> | |
console.log "Looking for #{pattern}" | |
while true | |
line = yield | |
if line.indexOf pattern != -1 | |
console.log "Found #{pattern} in #{line}" | |
on | |
g = grep("Coffee") | |
g.send("JavaScript") | |
g.send("CoffeeScript") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep, thanks, actually it's OK, just JS 1.7 was disabled. Coffee normally compiles
yield
as an identifier. Though, if to reserve it as the keyword, it should fail to compile whenyield
is used improperly.