Skip to content
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

Your Bug or Mine? #16

Closed
cortner opened this issue Feb 24, 2018 · 2 comments
Closed

Your Bug or Mine? #16

cortner opened this issue Feb 24, 2018 · 2 comments

Comments

@cortner
Copy link

cortner commented Feb 24, 2018

Hi - as mentioned I am trying to benchmark ResumableFunctions against other iteration protocols. The following below is something that is a bit on the simplistic side but reasonably close to a recent use-case I had. The println statements are for debugging since I got strange results.

using ResumableFunctions
using BenchmarkTools

@resumable function g(N)::Vector{Int}
   for n = 1:N
      println()
      println(n)
      for n1 = 1:10, n2 = 1:10
         print("*")
         # do something not terribly expensive
         x = rand(-10:10, 3)
         @yield x
      end
   end
   Int[]
end

f_resumable(N) = sum( sum(x) for x in g(N) )

f_resumable(100)

On Python-generators-v0.6 I get

1
*

as output which just means that it terminates after the first @yield. Why?

When I use the release for v0.6, the I get

1
*ERROR: UndefVarError: #temp# not defined
Stacktrace:
 [1] macro expansion at /Users/ortner/.julia/v0.6/ResumableFunctions/src/transforms.jl:14 [inlined]
 [2] (::##662)(::Void) at /Users/ortner/.julia/v0.6/MacroTools/src/utils.jl:12
 [3] next at ./generator.jl:44 [inlined]
 [4] mapfoldl_impl(::Base.#identity, ::Base.#+, ::Int64, ::Base.Generator{##662,Base.#sum}, ::UInt8) at ./reduce.jl:42
 [5] mapfoldl(::Base.#identity, ::Function, ::Base.Generator{##662,Base.#sum}) at ./reduce.jl:73
 [6] f_resumable(::Int64) at ./REPL[4]:1

which is probably related.

(just in case this turns out to be a stupid bug at my end, let me just apologise profusely in advance . . .)

@BenLauwens
Copy link
Collaborator

Duplicate of bug #14

@cortner
Copy link
Author

cortner commented Feb 24, 2018

Ups - sorry.

@cortner cortner closed this as completed Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants