- New type system capabilities (#8974, #18457)
- Type parameter constraints can refer to previous parameters, e.g.
type Foo{R<:Real, A<:AbstractArray{R}}
. Can also be used in method definitions. - New syntax
Array{T} where T<:Integer
, indicating a union of types over all specified values ofT
(represented by aUnionAll
type). This provides behavior similar to parametric methods ortypealias
, but can be used anywhere a type is accepted. This syntax can also be used in method definitions, e.g.function inv(M::Matrix{T}) where T<:AbstractFloat
. Anonymous functions can have type parameters via the syntax((x::Array{T}) where T<:Real) -> 2x
. - Implicit type parameters, e.g.
Vector{<:Real}
is equivalent toVector{T} where T<:Real
, and similarly forVector{>:Int}
(#20414). - Much more accurate subtype and type intersection algorithms. Method sorting and identification of equivalent and ambiguous methods are improved as a result.
- Type parameter constraints can refer to previous parameters, e.g.
-
"Inner constructor" syntax for parametric types is deprecated. For example, in this definition:
type Foo{T,S<:Real} x Foo(x) = new(x) end
the syntax
Foo(x) = new(x)
actually defined a constructor forFoo{T,S}
, i.e. the case where the type parameters are specified. For clarity, this definition now must be written asFoo{T,S}(x) where {T,S<:Real} = new(x)
. (#11310) -
The keywords used to define types have changed (#19157, #20418).
immutable
changes tostruct
type
changes tomutable struct
abstract
changes toabstract type ... end
bitstype 32 Char
changes toprimitive type Char 32 end
In 0.6,immutable
andtype
are still allowed as synonyms without a deprecation warning.
-
Multi-line and single-line nonstandard command literals have been added. A nonstandard command literal is like a nonstandard string literal, but the syntax uses backquotes (
`
) instead of double quotes, and the resulting macro called is suffixed with_cmd
. For instance, the syntaxq`xyz`
is equivalent to@q_cmd "xyz"
. (#18644) -
Nonstandard string and command literals can now be qualified with their module. For instance,
Base.r"x"
is now parsed asBase.@r_str "x"
. Previously, this syntax parsed as an implicit multiplication. (#18690) -
For every binary operator
⨳
,a .⨳ b
is now automatically equivalent to thebroadcast
call(⨳).(a, b)
. Hence, one no longer defines methods for.*
etcetera. This also means that "dot operations" automatically fuse into a single loop, along with other dot callsf.(x)
. (#17623) Similarly for unary operators (#20249). -
Newly defined methods are no longer callable from the same dynamic runtime scope they were defined in (#17057).
-
isa
is now parsed as an infix operator with the same precedence asin
(#19677). -
@.
is now parsed as@__dot__
, and can be used to add dots to every function call, operator, and assignment in an expression (#20321). -
The identifier
_
can be assigned, but accessing its value is deprecated, allowing this syntax to be used in the future for discarding values (#9343, #18251).
This section lists changes that do not have deprecation warnings.
-
readline
,readlines
andeachline
return lines without line endings by default. You must usereadline(s, chomp=false)
, etc. to get the old behavior where returned lines include trailing end-of-line character(s). (#19944) -
String
s no longer have a.data
field (as part of a significant performance improvement). UseVector{UInt8}(str)
to access a string as a byte array. However, allocating theVector
object has overhead. You can also usecodeunit(str, i)
to access thei
th byte of aString
. Usesizeof(str)
instead oflength(str.data)
, andpointer(str)
instead ofpointer(str.data)
. (#19449) -
Operations between
Float16
andIntegers
now returnFloat16
instead ofFloat32
. (#17261) -
Keyword arguments are processed left-to-right: if the same keyword is specified more than once, the rightmost occurrence takes precedence (#17785).
-
The
lgamma(z)
function now uses a different (more standard) branch cut forreal(z) < 0
, which differs fromlog(gamma(z))
by multiples of 2π in the imaginary part (#18330). -
broadcast
now handles tuples, and treats any argument that is not a tuple or an array as a "scalar" (#16986). -
broadcast
now produces aBitArray
instead ofArray{Bool}
for functions yielding a boolean result. If you wantArray{Bool}
, usebroadcast!
or.=
(#17623). -
Operations like
.+
and.*
onRange
objects are now genericbroadcast
calls (see above) and produce anArray
. If you want aRange
result, use+
and*
, etcetera (#17623). -
broadcast
now treatsRef
(except forPtr
) arguments as 0-dimensional arrays (#18965). -
broadcast
now handles missing data (Nullable
s) allowing operations to be lifted over mixtures ofNullable
s and scalars, as if theNullable
were like an array with zero or one element. (#16961, #19787). -
The runtime now enforces when new method definitions can take effect (#17057). The flip-side of this is that new method definitions should now reliably actually take effect, and be called when evaluating new code (#265).
-
The array-scalar operations
div
,mod
,rem
,&
,|
,xor
,/
,\
,*
,+
, and-
now follow broadcast promotion rules (#19692). -
broadcast!(f, A)
now callsf()
for each element ofA
, rather than doingfill!(A, f())
(#19722). -
rmprocs
now throws an exception if requested workers have not been completely removed beforewaitfor
seconds. With awaitfor=0
,rmprocs
returns immediately without waiting for worker exits. -
quadgk
has been moved from Base into a separate package. (#19741) -
The
Collections
module has been removed, and all functions defined therein have been moved to theDataStructures
package. (#19800) -
The
RepString
type has been moved to the LegacyStrings.jl package. -
In macro calls with parentheses, e.g.
@m(a=1)
, assignments are now parsed as=
expressions, instead of askw
expressions. (#7669) -
When used as an infix operator,
~
is now parsed as a call to an ordinary operator with assignment precedence, instead of as a macro call. (#20406) -
(µ "micro" and ɛ "latin epsilon") are considered equivalent to the corresponding Greek characters in identifiers.
\varepsilon
now tab-completes to U+03B5 (greek small letter epsilon) (#19464). -
retry
now inputs the keyword argumentsdelays
andcheck
instead ofn
andmax_delay
. The previous functionality can be achieved settingdelays
toExponentialBackOff
. (#19331) -
transpose(::AbstractVector)
now always returns aRowVector
view of the input (which is a special 1×n-sizedAbstractMatrix
), not aMatrix
, etc. In particular, forv::AbstractVector
we now have(v.').' === v
andv.' * v
is a scalar. (#19670) -
Parametric types with "unspecified" parameters, such as
Array
, are now represented asUnionAll
types instead ofDataType
s (#18457). -
Union
types have two fields,a
andb
, instead of a singletypes
field. The empty typeUnion{}
is represented by a singleton of typeBottomType
(#18457). -
The type
NTuple{N}
now refers to tuples where every element has the same type (since it is shorthand forNTuple{N,T} where T
). To get the old behavior of matching any tuple, useNTuple{N,Any}
(#18457). -
FloatRange
has been replaced byStepRangeLen
, and the internal representation ofLinSpace
has changed. Aside from changes in the internal field names, this leads to several differences in behavior (#18777):-
Both
StepRangeLen
andLinSpace
can represent ranges of arbitrary object types---they are no longer limited to floating-point numbers. -
For ranges that produce
Float64
,Float32
, orFloat16
numbers,StepRangeLen
can be used to produce values with little or no roundoff error due to internal arithmetic that is typically twice the precision of the output result. -
To take advantage of this precision,
linspace(start, stop, len)
now returns a range of typeStepRangeLen
rather thanLinSpace
whenstart
andstop
areFloatNN
.LinSpace(start, stop, len)
always returns aLinSpace
. -
StepRangeLen(a, step, len)
constructs an ordinary-precision range using the values and types ofa
andstep
as given, whereasrange(a, step, len)
will attempt to match inputsa::FloatNN
andstep::FloatNN
to rationals and construct aStepRangeLen
that internally uses twice-precision arithmetic. These two outcomes exhibit differences in both precision and speed.
-
-
A=>B
expressions are now parsed as calls instead of using=>
as the expression head (#20327). -
The
count
function no longer sums non-boolean values (#20404)
-
@views
macro to convert a whole expression or block of code to use views for all slices (#20164). -
max
,min
, and related functions (minmax
,maximum
,minimum
,extrema
) now returnNaN
forNaN
arguments (#12563). -
oneunit(x)
function to return a dimensionful version ofone(x)
(which is clarified to mean a dimensionless quantity ifx
is dimensionful) (#20268). -
The
chop
andchomp
functions now return aSubString
(#18339). -
Numbered stackframes printed in stacktraces can be opened in an editor by entering the corresponding number in the REPL and pressing
^Q
(#19680). -
The REPL now supports something called prompt pasting (#17599). This activates when pasting text that starts with
julia>
into the REPL. In that case, only expressions starting withjulia>
are parsed, the rest are removed. This makes it possible to paste a chunk of code that has been copied from a REPL session without having to scrub away prompts and outputs. This can be disabled or enabled at will withBase.REPL.enable_promptpaste(::Bool)
. -
The function
print_with_color
can now take a color represented by an integer between 0 and 255 inclusive as its first argument (#18473). For a number to color mapping please refer to this chart. It is also possible to use numbers as colors in environment variables that customizes colors in the REPL. For example, to get orange warning messages, simply setENV["JULIA_WARN_COLOR"] = 208
. Please note that not all terminals support 256 colors. -
The function
print_with_color
no longer prints text in bold by default (#18628). Instead, the function now take a keyword argumentbold::Bool
which determines whether to print in bold or not. On some terminals, printing a color in non bold results in slightly darker colors being printed than when printing in bold. Therefore, light versions of the colors are now supported. For the available colors see the help entry onprint_with_color
. -
The default text style for REPL input and answers has been changed from bold to normal (#11250). They can be changed back to bold by setting the environment variables
JULIA_INPUT_COLOR
andJULIA_ANSWER_COLOR
to"bold"
. For example, one way of doing this is addingENV["JULIA_INPUT_COLOR"] = :bold
andENV["JULIA_ANSWER_COLOR"] = :bold
to the.juliarc.jl
file. See the manual section on customizing colors for more information. -
The default color for info messages has been changed from blue to cyan (#18442), and for warning messages from red to yellow (#18453). This can be changed back to the original colors by setting the environment variables
JULIA_INFO_COLOR
to"blue"
andJULIA_WARN_COLOR
to"red"
. -
Iteration utilities that wrap iterators and return other iterators (
enumerate
,zip
,rest
,countfrom
,take
,drop
,cycle
,repeated
,product
,flatten
,partition
) have been moved to the moduleBase.Iterators
(#18839). -
BitArrays can now be constructed from arbitrary iterables, in particular from generator expressions, e.g.
BitArray(isodd(x) for x = 1:100)
(#19018). -
hcat
,vcat
, andhvcat
now work withUniformScaling
objects, so you can now do e.g.[A I]
and it will concatenate an appropriately sized identity matrix (#19305). -
New
accumulate
andaccumulate!
functions, which generalizecumsum
andcumprod
. Also known as a scan operation (#18931). -
reshape
now allows specifying one dimension with aColon()
(:
) for the new shape, in which case that dimension's length will be computed such that its product with all the other dimensions is equal to the length of the original array (#19919). -
New
titlecase
function, which capitalizes the first character of each word within a string (#19469). -
any
andall
now always short-circuit, andmapreduce
never short-circuits (#19543). That is, not every member of the input iterable will be visited if atrue
(in the case ofany
) orfalse
(in the case ofall
) value is found, andmapreduce
will visit all members of the iterable. -
Additional methods for
ones
andzeros
functions to support the same signature as thesimilar
function (#19635). -
count
now has acount(itr)
method equivalent tocount(identity, itr)
(#20403). -
Methods for
map
andfilter
withNullable
arguments have been implemented; the semantics are as if theNullable
were a container with zero or one elements (#16961). -
New
@test_warn
and@test_nowarn
macros in theBase.Test
module to test for the presence or absence of warning messages (#19903). -
logging
can be used to redirectinfo
,warn
, anderror
messages either universally or on a per-module/function basis (#16213). -
New
iszero(x)
function to quickly check whetherx
is zero (or is all zeros, for an array) (#19950). -
notify
now returns a count of tasks woken up (#19841). -
New nonstandard string literal
raw"..."
for creating strings with no interpolation or unescaping (#19900). -
A new
Dates.Time
type was added that supports representing the time of day with up to nanosecond resolution (#12274). -
New
@macroexpand
macro as a convenient alternative to themacroexpand
function (#18660). -
Introduced a wrapper type for lazy complex conjugation of arrays,
ConjArray
. Currently, it is used by default for the newRowVector
type only, and enforces that bothtranspose(vec)
andctranspose(vec)
are views not copies (#20047).
-
ccall
is now implemented as a macro, removing the need for special code-generator support for Intrinsics. -
ccall
gained limited support for allvmcall
calling-convention. This can replace many uses ofllvmcall
with a simpler, shorter declaration. -
All Intrinsics are now Builtin functions instead and have proper error checking and fall-back static compilation support.
-
Linear indexing is now only supported when there is exactly one non-cartesian index provided. Allowing a trailing index at dimension
d
to linearly access the higher dimensions from arrayA
(beyondsize(A, d)
) has been deprecated as a stricter constraint during bounds checking. Instead,reshape
the array such that its dimensionality matches the number of indices (#20079). -
isdefined(a::Array, i::Int)
has been deprecated in favor ofisassigned
(#18346). -
is
has been deprecated in favor of===
(which used to be an alias foris
) (#17758). -
num
andden
have been deprecated in favor ofnumerator
anddenominator
respectively (#19233). -
infix operator
$
has been deprecated in favor of infix⊻
or functionxor()
(#18977). -
Dates.recur
has been deprecated in favor offilter
(#19288) -
cummin
andcummax
have been deprecated in favor ofaccumulate
. -
sumabs
andsumabs2
have been deprecated in favor ofsum(abs, x)
andsum(abs2, x)
, respectively.maxabs
andminabs
have similarly been deprecated in favor ofmaximum(abs, x)
andminimum(abs, x)
. Likewise for the in-place counterparts of these functions (#19598). -
airy
,airyx
andairyprime
have been deprecated in favor of more specific functions (airyai
,airybi
,airyaiprime
,airybiprimex
,airyaix
,airybix
,airyaiprimex
,airybiprimex
) (#18050). -
produce
,consume
and iteration over a Task object have been deprecated in favor of using Channels for inter-task communication (#19841). -
@test_approx_eq x y
has been deprecated in favor of@test isapprox(x,y)
or@test x ≈ y
(#4615).