-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
conditional expressions that eagerly evaluate the condition at top-level? #5892
Labels
speculative
Whether the change will be implemented is speculative
Comments
It would be nice to call this |
crossref #7449 which covers one of the use-cases. |
I implemented this for Lazy.jl so that you can do things like @cond if WINDOWS
foo()
elseif OSX
bar()
else
error()
end It supports chains of both block and ternary if syntax (you could even mix them I guess, yay recursive macros). Base is welcome to it. |
vtjnash
added a commit
to vtjnash/julia
that referenced
this issue
May 6, 2016
implements JuliaLang#5892 closes JuliaLang#6674 and JuliaLang#4233
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be great to do things like:
This would fix #4233 as well as give us an approach to writing code that is compatible with multiple Julia or package versions that isn't as awkward as #5029. (It would be great to have something like this for 0.3, so that package authors can avoid separate branches for different Julia versions provided the differences aren't too big.) I'm not sure how to do this, though. It seems like
@cond
would have to be a macro that callseval
. Ignoring that this is considered bad practice, the argument toeval
seems to be executed in the macro's module and not the calling module, which could be confusing. Any thoughts?The text was updated successfully, but these errors were encountered: