-
Notifications
You must be signed in to change notification settings - Fork 28
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
@require-else #41
Comments
This doesn't really work in Requires' model, since HTTP could be loaded at any time. So it'd have be have semantics more like get_header(url) = readstring(...)
@require HTTP get_header(url) = HTTP... This will get you an ugly method definition warning though; it's probably better to just to get_headers(url) = isdefined(Main, :HTTP) ? ... |
Performace-wise that would be sub-optimal, but it is probably negligible anyway, since it is no fast operation to begin with. Just checking main probably isn't enough since my package could be being used from within another module which has loaded HTTP.jl (because that package might know that they need HTTP's extra robustness) (cf: oxinabox/DataDeps.jl#23) |
Checking Not sure how this changes on 0.7 though. |
This is very useful! For example, I can use two different methods for a function depending on the @requires output. |
Could we have a kind of If else block?
I'm thinking I would like to
@require
HTTP.jl,but if that hasn't been loaded,
then fallback to defining my methods in terms of called to
run(`curl ...`)
So that would look something like (and I am making up syntax)
This task actually takes something way more complex but I am sure you see the point
The text was updated successfully, but these errors were encountered: