Skip to content

Commit

Permalink
Doc-strings for some internals. (#23333)
Browse files Browse the repository at this point in the history
* REPL-documentation for more internals.

* Copy edit 'REPL-documentation for more internals.'

* New section "Special Types"
  • Loading branch information
mschauer authored and fredrikekre committed Aug 24, 2017
1 parent 03c5d7d commit 8809617
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 3 deletions.
127 changes: 127 additions & 0 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1261,4 +1261,131 @@ available in the `.error` field.
"""
InitError

"""
Any::DataType
`Any` is the union of all types. It has the defining property `isa(x, Any) == true` for any `x`. `Any` therefore
describes the entire universe of possible values. For example `Integer` is a subset of `Any` that includes `Int`,
`Int8`, and other integer types.
"""
Any

"""
Union{}
`Union{}`, the empty [`Union`](@ref) of types, is the type that has no values. That is, it has the defining
property `isa(x, Union{}) == false` for any `x`. `Base.Bottom` is defined as its alias and the type of `Union{}`
is `Core.TypeofBottom`.
# Examples
```jldoctest
julia> isa(nothing, Union{})
false
```
"""
kw"Union{}", Base.Bottom

"""
Union{Types...}
A type union is an abstract type which includes all instances of any of its argument types. The empty
union [`Union{}`](@ref) is the bottom type of Julia.
# Examples
```jldoctest
julia> IntOrString = Union{Int,AbstractString}
Union{AbstractString, Int64}
julia> 1 :: IntOrString
1
julia> "Hello!" :: IntOrString
"Hello!"
julia> 1.0 :: IntOrString
ERROR: TypeError: typeassert: expected Union{AbstractString, Int64}, got Float64
```
"""
Union


"""
UnionAll
A union of types over all values of a type parameter. `UnionAll` is used to describe parametric types
where the values of some parameters are not known.
# Examples
```jldoctest
julia> typeof(Vector)
UnionAll
julia> typeof(Vector{Int})
DataType
```
"""
UnionAll

"""
::
With the `::`-operator type annotations are attached to expressions and variables in programs.
See the manual section on [Type Declarations](@ref).
Outside of declarations `::` is used to assert that expressions and variables in programs have a given type.
# Examples
```jldoctest
julia> (1+2)::AbstractFloat
ERROR: TypeError: typeassert: expected AbstractFloat, got Int64
julia> (1+2)::Int
3
```
"""
kw"::"

"""
Vararg{T,N}
The last parameter of a tuple type [`Tuple`](@ref) can be the special type `Vararg`, which denotes any
number of trailing elements. The type `Vararg{T,N}` corresponds to exactly `N` elements of type `T`.
`Vararg{T}` corresponds to zero or more elements of type `T`. `Vararg` tuple types are used to represent the
arguments accepted by varargs methods (see the section on [Varargs Functions](@ref) in the manual.)
# Examples
```jldoctest
julia> mytupletype = Tuple{AbstractString,Vararg{Int}}
Tuple{AbstractString,Vararg{Int64,N} where N}
julia> isa(("1",), mytupletype)
true
julia> isa(("1",1), mytupletype)
true
julia> isa(("1",1,2), mytupletype)
true
julia> isa(("1",1,2,3.0), mytupletype)
false
```
"""
Vararg

"""
Tuple{Types...}
Tuples are an abstraction of the arguments of a function – without the function itself. The salient aspects of
a function's arguments are their order and their types. Therefore a tuple type is similar to a parameterized
immutable type where each parameter is the type of one field. Tuple types may have any number of parameters.
Tuple types are covariant in their parameters: `Tuple{Int}` is a subtype of `Tuple{Any}`. Therefore `Tuple{Any}`
is considered an abstract type, and tuple types are only concrete if their parameters are. Tuples do not have
field names; fields are only accessed by index.
See the manual section on [Tuple Types](@ref).
"""
Tuple

end
17 changes: 14 additions & 3 deletions doc/src/stdlib/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Base.widen
Base.identity
```

## Types
## Dealing with Types

```@docs
Base.supertype
Expand All @@ -109,11 +109,22 @@ Base.isbits
Base.isleaftype
Base.typejoin
Base.typeintersect
Base.Val
Base.Enums.@enum
Base.instances
```

## Special Types

```@docs
Core.Any
Base.Enums.@enum
Core.Union
Union{}
Core.UnionAll
Core.Tuple
Base.Val
Core.Vararg
```

## Generic Functions

```@docs
Expand Down

0 comments on commit 8809617

Please sign in to comment.