From ed7209e990f834bd3586b234354edb4f97e36102 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 30 Jun 2015 16:11:55 -0400 Subject: [PATCH] Compat for JuliaLang/julia#11922 (MathConst -> Irrational) Fixes #108 --- README.md | 4 ++++ src/Compat.jl | 8 ++++++++ test/runtests.jl | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 6bdacbdec..c68fdf40b 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ Currently, the `@compat` macro supports the following syntaxes: Julia 0.4, using these types also checks whether the string has embedded NUL characters [#10994](https://github.com/JuliaLang/julia/pull/10994).) +* `typealias Irrational MathConst` - `MathConst` has been renamed to `Irrational` [#11922](https://github.com/JuliaLang/julia/pull/11922) + ## New functions * `eachindex`, as in `for i in eachindex(A)`, can be used in julia 0.3. This is the recommended way to iterate over each index in an `AbstractArray`. On julia 0.3 `eachindex` just returns `1:length(A)`, but in julia 0.4 it can return a more sophisticated iterator. @@ -111,6 +113,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `zero(Ptr{T})` is now `Ptr{T}(0)` [#8909](https://github.com/JuliaLang/julia/pull/8909) +* The unexported macro `Base.@math_const` was renamed to `Base.@irrational`, accessible as `Compat.@irrational` on either 0.3 or 0.4 [#11922](https://github.com/JuliaLang/julia/pull/11922) + ## New types * [`Nullable` types](http://julia.readthedocs.org/en/latest/manual/types/?highlight=nullable#nullable-types-representing-missing-values) and their associated operations. diff --git a/src/Compat.jl b/src/Compat.jl index 7b3c75928..62f081299 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -459,4 +459,12 @@ if VERSION < v"0.4.0-dev+5322" include("timer.jl") end +if VERSION < v"0.4.0-dev+5688" + typealias Irrational MathConst + @eval $(symbol("@irrational")) = getfield(Base, symbol("@math_const")) + export Irrational +else + import Base.@irrational +end + end # module diff --git a/test/runtests.jl b/test/runtests.jl index 488e18ee2..7e028b8ff 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -357,3 +357,9 @@ let c = 0, f, t sleep(0.1) @test val == c end + +# MathConst -> Irrational +f(::Irrational) = true +@test f(π) +Compat.@irrational mathconst_one 1.0 big(1.) +@test f(mathconst_one)