Skip to content

Commit

Permalink
Compat for JuliaLang/julia#11922 (MathConst -> Irrational)
Browse files Browse the repository at this point in the history
Fixes #108
  • Loading branch information
simonster committed Jun 30, 2015
1 parent 3ecf55d commit ed7209e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/Compat.jl
Expand Up @@ -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
6 changes: 6 additions & 0 deletions test/runtests.jl
Expand Up @@ -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)

0 comments on commit ed7209e

Please sign in to comment.