Skip to content

Commit 0010aaf

Browse files
authored
Merge branch 'master' into stabilize-quicksort
2 parents 1a30832 + a74ef57 commit 0010aaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1191
-553
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ Standard library changes
8787

8888
#### REPL
8989

90+
* `Meta-e` now opens the current input in an editor. The content (if modified) will be
91+
executed upon existing the editor.
92+
9093
#### SparseArrays
9194

9295
#### Dates

base/array.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ julia> a = Base.vect(UInt8(1), 2.5, 1//2)
142142
"""
143143
function vect(X...)
144144
T = promote_typeof(X...)
145-
#T[ X[i] for i=1:length(X) ]
146-
# TODO: this is currently much faster. should figure out why. not clear.
147-
return copyto!(Vector{T}(undef, length(X)), X)
145+
return T[X...]
148146
end
149147

150148
size(a::Array, d::Integer) = arraysize(a, convert(Int, d))

base/combinatorics.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ end
164164
Permute vector `v` in-place, according to permutation `p`. No checking is done
165165
to verify that `p` is a permutation.
166166
167-
To return a new permutation, use `v[p]`. Note that this is generally faster than
168-
`permute!(v,p)` for large vectors.
167+
To return a new permutation, use `v[p]`. Note that this is faster than `permute!(v, p)`.
169168
170169
See also [`invpermute!`](@ref).
171170
@@ -185,7 +184,7 @@ julia> A
185184
1
186185
```
187186
"""
188-
permute!(a, p::AbstractVector) = permute!!(a, copymutable(p))
187+
permute!(v, p::AbstractVector) = (v .= v[p])
189188

190189
function invpermute!!(a, p::AbstractVector{<:Integer})
191190
require_one_based_indexing(a, p)
@@ -232,7 +231,7 @@ julia> A
232231
1
233232
```
234233
"""
235-
invpermute!(a, p::AbstractVector) = invpermute!!(a, copymutable(p))
234+
invpermute!(v, p::AbstractVector) = (v[p] = v; v)
236235

237236
"""
238237
invperm(v)

base/dict.jl

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
function _truncate_at_width_or_chars(str, width, chars="", truncmark="")
4-
truncwidth = textwidth(truncmark)
5-
(width <= 0 || width < truncwidth) && return ""
6-
7-
wid = truncidx = lastidx = 0
8-
for (idx, c) in pairs(str)
9-
lastidx = idx
10-
wid += textwidth(c)
11-
wid >= width - truncwidth && truncidx == 0 && (truncidx = lastidx)
12-
(wid >= width || c in chars) && break
13-
end
14-
15-
lastidx != 0 && str[lastidx] in chars && (lastidx = prevind(str, lastidx))
16-
truncidx == 0 && (truncidx = lastidx)
17-
if lastidx < lastindex(str)
18-
return String(SubString(str, 1, truncidx) * truncmark)
19-
else
20-
return String(str)
21-
end
22-
end
23-
243
function show(io::IO, t::AbstractDict{K,V}) where V where K
254
recur_io = IOContext(io, :SHOWN_SET => t,
265
:typeinfo => eltype(t))

base/docs/basedocs.jl

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,53 @@ julia> z
279279
"""
280280
kw"global"
281281

282+
"""
283+
for outer
284+
285+
Reuse an existing local variable for iteration in a `for` loop.
286+
287+
See the [manual section on variable scoping](@ref scope-of-variables) for more information.
288+
289+
See also [`for`](@ref).
290+
291+
292+
# Examples
293+
```jldoctest
294+
julia> function f()
295+
i = 0
296+
for i = 1:3
297+
# empty
298+
end
299+
return i
300+
end;
301+
302+
julia> f()
303+
0
304+
```
305+
306+
```jldoctest
307+
julia> function f()
308+
i = 0
309+
for outer i = 1:3
310+
# empty
311+
end
312+
return i
313+
end;
314+
315+
julia> f()
316+
3
317+
```
318+
319+
```jldoctest
320+
julia> i = 0 # global variable
321+
for outer i = 1:3
322+
end
323+
ERROR: syntax: no outer local variable declaration exists for "for outer"
324+
[...]
325+
```
326+
"""
327+
kw"outer"
328+
282329
"""
283330
' '
284331
@@ -834,6 +881,10 @@ kw"?", kw"?:"
834881
`for` loops repeatedly evaluate a block of statements while
835882
iterating over a sequence of values.
836883
884+
The iteration variable is always a new variable, even if a variable of the same name
885+
exists in the enclosing scope.
886+
Use [`outer`](@ref) to reuse an existing local variable for iteration.
887+
837888
# Examples
838889
```jldoctest
839890
julia> for i in [1, 4, 0]
@@ -1970,9 +2021,8 @@ julia> eval(:x)
19702021
`Symbol`s can also be constructed from strings or other values by calling the
19712022
constructor `Symbol(x...)`.
19722023
1973-
`Symbol`s are immutable and should be compared using `===`.
1974-
The implementation re-uses the same object for all `Symbol`s with the same name,
1975-
so comparison tends to be efficient (it can just compare pointers).
2024+
`Symbol`s are immutable and their implementation re-uses the same object for all `Symbol`s
2025+
with the same name.
19762026
19772027
Unlike strings, `Symbol`s are "atomic" or "scalar" entities that do not support
19782028
iteration over characters.

base/errorshow.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ function showerror(io::IO, ex::MethodError)
272272
if !isempty(kwargs)
273273
print(io, "; ")
274274
for (i, (k, v)) in enumerate(kwargs)
275-
print(io, k, "=")
276-
show(IOContext(io, :limit => true), v)
275+
print(io, k, "::", typeof(v))
277276
i == length(kwargs)::Int || print(io, ", ")
278277
end
279278
end

base/exports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ export
882882
basename,
883883
dirname,
884884
expanduser,
885+
contractuser,
885886
homedir,
886887
isabspath,
887888
isdirpath,

base/int.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ julia> string(bswap(1), base = 2)
387387
"100000000000000000000000000000000000000000000000000000000"
388388
```
389389
"""
390-
bswap(x::Union{Int8, UInt8}) = x
390+
bswap(x::Union{Int8, UInt8, Bool}) = x
391391
bswap(x::Union{Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128}) =
392392
bswap_int(x)
393393

base/multidimensional.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,9 @@ end
15461546
end
15471547
end
15481548

1549+
isassigned(a::AbstractArray, i::CartesianIndex) = isassigned(a, Tuple(i)...)
1550+
isassigned(a::AbstractArray, i::Union{Integer, CartesianIndex}...) = isassigned(a, CartesianIndex(i))
1551+
15491552
## permutedims
15501553

15511554
## Permute array dims ##

base/multimedia.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ for that case. If a type benefits from custom human-readable output though,
104104
`show(::IO, ::MIME"text/plain", ::T)` should be defined. For example, the `Day` type uses
105105
`1 day` as the output for the `text/plain` MIME type, and `Day(1)` as the output of 2-argument `show`.
106106
107+
# Examples
108+
```jldoctest
109+
julia> struct Day
110+
n::Int
111+
end
112+
113+
julia> Base.show(io::IO, ::MIME"text/plain", d::Day) = print(io, d.n, " day")
114+
115+
julia> Day(1)
116+
1 day
117+
```
118+
107119
Container types generally implement 3-argument `show` by calling `show(io, MIME"text/plain"(), x)`
108120
for elements `x`, with `:compact => true` set in an [`IOContext`](@ref) passed as the first argument.
109121
"""

0 commit comments

Comments
 (0)