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

Compat for JuliaLang/julia#11922 (MathConst -> Irrational) #109

Merged
merged 1 commit into from
Jul 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 const $(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
Original file line number Diff line number Diff line change
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)