Macro for optional threading not working

macro optthreads(switch,code)
    :(
    if $(esc(switch))
        esc(:(Threads.@threads $$code))
    else
        $(esc(code))
    end
    )
end

function test(par)
    @optthreads par for i in 1:80
        print(Threads.threadid())
    end
end

test(true)

i cannot seem to figure how to correctly nest a macro inside a macro, can anybody please help?

1 Like

you sir are the best