Skip to content

Commit

Permalink
Move docstrings from helpdb inline (#22617)
Browse files Browse the repository at this point in the history
  • Loading branch information
xorJane authored and tkelman committed Jun 30, 2017
1 parent 46ac6d9 commit bbc516c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 80 deletions.
20 changes: 20 additions & 0 deletions base/deepcopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@
# Note: deepcopy_internal(::Any, ::ObjectIdDict) is
# only exposed for specialization by libraries

"""
deepcopy(x)
Create a deep copy of `x`: everything is copied recursively, resulting in a fully
independent object. For example, deep-copying an array produces a new array whose elements
are deep copies of the original elements. Calling `deepcopy` on an object should generally
have the same effect as serializing and then deserializing it.
As a special case, functions can only be actually deep-copied if they are anonymous,
otherwise they are just copied. The difference is only relevant in the case of closures,
i.e. functions which may contain hidden internal references.
While it isn't normally necessary, user-defined types can override the default `deepcopy`
behavior by defining a specialized version of the function
`deepcopy_internal(x::T, dict::ObjectIdDict)` (which shouldn't otherwise be used),
where `T` is the type to be specialized for, and `dict` keeps track of objects copied
so far within the recursion. Within the definition, `deepcopy_internal` should be used
in place of `deepcopy`, and the `dict` variable should be
updated as appropriate before returning.
"""
deepcopy(x) = deepcopy_internal(x, ObjectIdDict())::typeof(x)

deepcopy_internal(x::Union{Symbol,Core.MethodInstance,Method,GlobalRef,DataType,Union,Task},
Expand Down
80 changes: 0 additions & 80 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2270,86 +2270,6 @@ also be skipped.
"""
skipchars

"""
realmin(T)
The smallest in absolute value non-subnormal value representable by the given floating-point DataType `T`.
"""
realmin

"""
deepcopy(x)
Create a deep copy of `x`: everything is copied recursively, resulting in a fully
independent object. For example, deep-copying an array produces a new array whose elements
are deep copies of the original elements. Calling `deepcopy` on an object should generally
have the same effect as serializing and then deserializing it.
As a special case, functions can only be actually deep-copied if they are anonymous,
otherwise they are just copied. The difference is only relevant in the case of closures,
i.e. functions which may contain hidden internal references.
While it isn't normally necessary, user-defined types can override the default `deepcopy`
behavior by defining a specialized version of the function `deepcopy_internal(x::T, dict::ObjectIdDict)`
(which shouldn't otherwise be used), where `T` is the type to be specialized for, and `dict`
keeps track of objects copied so far within the recursion. Within the definition,
`deepcopy_internal` should be used in place of `deepcopy`, and the `dict` variable should be
updated as appropriate before returning.
"""
deepcopy

"""
widen(x)
If `x` is a type, return a "larger" type (for numeric types, this will be
a type with at least as much range and precision as the argument, and usually more).
Otherwise `x` is converted to `widen(typeof(x))`.
# Examples
```jldoctest
julia> widen(Int32)
Int64
julia> widen(1.5f0)
1.5
```
"""
widen

"""
signed(x)
Convert a number to a signed integer. If the argument is unsigned, it is reinterpreted as
signed without checking for overflow.
"""
signed

"""
Val{c}
Create a "value type" out of `c`, which must be an `isbits` value. The intent of this
construct is to be able to dispatch on constants, e.g., `f(Val{false})` allows you to
dispatch directly (at compile-time) to an implementation `f(::Type{Val{false}})`, without
having to test the boolean value at runtime.
"""
Val

"""
|(x, y)
Bitwise or.
# Examples
```jldoctest
julia> 4 | 10
14
julia> 4 | 1
5
```
"""
Base.:(|)

"""
pop!(collection, key[, default])
Expand Down
8 changes: 8 additions & 0 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ end
const (:) = Colon()

# For passing constants through type inference
"""
Val{c}
Create a "value type" out of `c`, which must be an `isbits` value. The intent of this
construct is to be able to dispatch on constants, e.g., `f(Val{false})` allows you to
dispatch directly (at compile-time) to an implementation `f(::Type{Val{false}})`, without
having to test the boolean value at runtime.
"""
struct Val{T}
end

Expand Down
7 changes: 7 additions & 0 deletions base/float.jl
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,13 @@ end
realmax(::Type{Float16}) = $(bitcast(Float16, 0x7bff))
realmax(::Type{Float32}) = $(bitcast(Float32, 0x7f7fffff))
realmax(::Type{Float64}) = $(bitcast(Float64, 0x7fefffffffffffff))

"""
realmin(T)
The smallest in absolute value non-subnormal value representable by the given
floating-point DataType `T`.
"""
realmin(x::T) where {T<:AbstractFloat} = realmin(T)
realmax(x::T) where {T<:AbstractFloat} = realmax(T)
realmin() = realmin(Float64)
Expand Down
22 changes: 22 additions & 0 deletions base/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ unsigned(x::Signed) = reinterpret(typeof(convert(Unsigned, zero(x))), x)
unsigned(x::Bool) = convert(Unsigned, x)
unsigned(x) = convert(Unsigned, x)
signed(x::Unsigned) = reinterpret(typeof(convert(Signed, zero(x))), x)

"""
signed(x)
Convert a number to a signed integer. If the argument is unsigned, it is reinterpreted as
signed without checking for overflow.
"""
signed(x) = convert(Signed, x)

div(x::Signed, y::Unsigned) = flipsign(signed(div(unsigned(abs(x)), y)), x)
Expand Down Expand Up @@ -207,6 +214,21 @@ end

(~)(x::BitInteger) = not_int(x)
(&)(x::T, y::T) where {T<:BitInteger} = and_int(x, y)

"""
|(x, y)
Bitwise or.
# Examples
```jldoctest
julia> 4 | 10
14
julia> 4 | 1
5
```
"""
(|)(x::T, y::T) where {T<:BitInteger} = or_int(x, y)
xor(x::T, y::T) where {T<:BitInteger} = xor_int(x, y)

Expand Down
16 changes: 16 additions & 0 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,22 @@ For matrices or vectors ``A`` and ``B``, calculates ``Aᴴ`` \\ ``Bᵀ``.
"""
Ac_ldiv_Bt(a,b) = Ac_ldiv_B(a,transpose(b))

"""
widen(x)
If `x` is a type, return a "larger" type (for numeric types, this will be
a type with at least as much range and precision as the argument, and usually more).
Otherwise `x` is converted to `widen(typeof(x))`.
# Examples
```jldoctest
julia> widen(Int32)
Int64
julia> widen(1.5f0)
1.5
```
"""
widen(x::T) where {T<:Number} = convert(widen(T), x)

# function pipelining
Expand Down

0 comments on commit bbc516c

Please sign in to comment.