Hello, 

I think I want to use the `@task` idiom for a generator, but I can't wrap 
my head around macros, so I don't understand where this goes wrong:

linebyline(file::IO) = @task while !eof(file)
    produce(readline(file))
end


linebyline(file::AbstractString) = open(file) do fd
    linebyline(fd)
end



The first construction works, and operates on a `IO` object.  If I want to 
dispatch the same construction using a file name, as in the second example, 
I get an empty result. 

for line in linebyline("input.txt") ## `linebyline(open("input.txt"))` 
would work here
       println(line)
end

## nothing happens here


I think I don't understand macros, I generally try to evade them, but the 
generator construction is quite nice. 


---david


Reply via email to