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

Add support for multiple packages in @require statement #54

Closed
juliohm opened this issue Aug 25, 2018 · 2 comments
Closed

Add support for multiple packages in @require statement #54

juliohm opened this issue Aug 25, 2018 · 2 comments

Comments

@juliohm
Copy link
Contributor

juliohm commented Aug 25, 2018

Sometimes a functionality depends on a combination of packages, and it would be nice to have a syntax for that, something like @require PkgA="..." PkgB="..." include("file.jl")

As discussed on slack, a current workaround is to do something like:

pkgA = false
pkgB = false
@require PkgA begin
 global pkgA = true
 pkgA && pkgB && include("file.jl")
end
@require PkgB begin
 global pkgB = true
 pkgA && pkgB && include("file.jl")
end

but that solution is too verbose for more than 2 packages.

@timholy
Copy link
Member

timholy commented Jan 8, 2019

Do we really need anything special here?

module TestRequires

using Requires

function __init__()
    @require Images="916415d5-f1e6-5110-898d-aaa5f9f070e0" begin
        @require Revise="295af30f-e4ad-537b-8983-00126c2a3abe" println("Got both!")
    end
end

end # module

Session:

julia> using TestRequires
[ Info: Precompiling TestRequires [eb9e79a2-1324-11e9-3469-91075b92f61d]

julia> using Images

julia> using Revise
[ Info: Recompiling stale cache file /tmp/pkgs/compiled/v1.0/Revise/M1Qoh.ji for Revise [295af30f-e4ad-537b-8983-00126c2a3abe]
Got both!

@juliohm
Copy link
Contributor Author

juliohm commented Jan 8, 2019

Clever! 💯

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