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

@static && || syntax #17498

Merged
merged 1 commit into from
Dec 22, 2016
Merged

@static && || syntax #17498

merged 1 commit into from
Dec 22, 2016

Conversation

bjarthur
Copy link
Contributor

expands @static syntax to include short-circuit evaluation, to facilitate making the build scripts for some packages (e.g. ImageMagick) more concise.

@vtjnash
Copy link
Member

vtjnash commented Jul 19, 2016

build scripts don't really need @static, they can just use normal conditionals. but anyways, this lgtm.

@@ -56,12 +56,13 @@ Partially evaluates an expression at parse time.
For example, `@static is_windows() ? foo : bar` will evaluate `is_windows()` and insert either `foo` or `bar` into the expression.
This is useful in cases where a construct would be invalid on other platforms,
such as a `ccall` to a non-existent function.
`@static if is_apple() foo end` and `@static is_linux() <&&,||> foo` are also valid syntax.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need a make docs run then commit the rst

@bjarthur
Copy link
Contributor Author

docs are committed and checks have passed

@test (@static if true 1 end) == 1
@test (@static if false 1 end) == nothing
@test (@static true && 1) == 1
@test (@static false && 1) == nothing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually return false? Similarly the || one below should return true.

@bjarthur
Copy link
Contributor Author

thanks @yuyichao. fixed. tests are passing on 64-bit.

@bjarthur
Copy link
Contributor Author

now that the flurry of 0.5 activity has passed, come someone please look over this again?

@StefanKarpinski
Copy link
Member

LGTM, although I'm not 100% on what needs to be done to add a file to the test suite these days.

@tkelman
Copy link
Contributor

tkelman commented Sep 27, 2016

was done correctly here, but these are short and could easily have been added to one of the existing files

@StefanKarpinski
Copy link
Member

bump? rebase?

@@ -0,0 +1,8 @@
@test (@static true ? 1 : 2) == 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still better to just add these lines to one of the existing test files imo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about test/misc.jl. there are only a couple of uses of at-static in existing tests, it doesn't appear to have dedicated unit tests of its own yet

Copy link
Contributor Author

@bjarthur bjarthur Dec 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm easy. by putting it in test/osutils.jl i was just trying to mimic the pattern that there is generally a 1:1 correspondence between base/*.jl and test/*.jl. will make the change as soon as the current CI finishes so i know if there are any other problems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other alternative is keeping an osutils.jl test file but making it worth the cost of spawning another test process by moving a few of the existing relevant os tests from other files into it.

@test (@static false ? 1 : 2) == 2
@test (@static if true 1 end) == 1
@test (@static if false 1 end) == nothing
@test (@static true && 1) == 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I'd also make these tests more picky by using === to check type equality too

@vtjnash vtjnash merged commit d47f24b into JuliaLang:master Dec 22, 2016
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

Successfully merging this pull request may close these issues.

6 participants