Hacker News new | ask | show | jobs
by mamcx 2220 days ago
I have thinking something similar but with generators:

    //A async candidate
    fun read_lines(file):
        for line in file:
            yield line  }

    let lines = read_lines("hello.txt").await //turn async 

I wonder why something like this is not used. Exist a bad interaction that could arise from this? Maybe about how nest stuff?

    fun uppercase_lines(file):
        for line in read_lines(file):
            yield line

    let lines = uppercase_lines("hello.txt").await //turn async, but also recursivelly read_lines?
1 comments

How do you plan on making this concurrent? Generators can defer computation for later, but that doesn't magically make them async.
The assumption is that exist a desugaring step in the compiler/interpreted to async/await/futures.