Skip to content

Commit

Permalink
Merge branch 'master' into jn/grabbag-subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Feb 10, 2017
2 parents dee86b3 + 08cb76b commit 3159acc
Show file tree
Hide file tree
Showing 340 changed files with 3,892 additions and 2,741 deletions.
12 changes: 9 additions & 3 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ else
build_shlibdir := $(build_libdir)
endif
ifeq ($(OS), FreeBSD)
LOCALBASE ?= /usr/local
else
LOCALBASE ?= /usr
endif
ifeq (exists, $(shell [ -e $(JULIAHOME)/Make.user ] && echo exists ))
include $(JULIAHOME)/Make.user
endif
Expand Down Expand Up @@ -837,16 +843,16 @@ LIBMNAME := libopenlibm
endif

ifeq ($(USE_SYSTEM_LIBUV), 1)
LIBUV := /usr/lib/libuv-julia.a
LIBUV_INC := /usr/include
LIBUV := $(LOCALBASE)/lib/libuv-julia.a
LIBUV_INC := $(LOCALBASE)/include
else
LIBUV := $(build_libdir)/libuv.a
LIBUV_INC := $(build_includedir)
endif

ifeq ($(USE_SYSTEM_UTF8PROC), 1)
LIBUTF8PROC := -lutf8proc
UTF8PROC_INC := /usr/include
UTF8PROC_INC := $(LOCALBASE)/include
else
LIBUTF8PROC := $(build_libdir)/libutf8proc.a
UTF8PROC_INC := $(build_includedir)
Expand Down
31 changes: 31 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ New language features
Language changes
----------------

* "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 for `Foo{T,S}`,
i.e. the case where the type parameters are specified. For clarity, this
definition now must be written as `Foo{T,S}(x) where {T,S<:Real} = new(x)`. ([#11310])

* The keywords used to define types have changed ([#19157], [#20418]).
+ `immutable` changes to `struct`
+ `type` changes to `mutable struct`
+ `abstract` changes to `abstract type ... end`
+ `bitstype 32 Char` changes to `primitive type Char 32 end`
In 0.6, `immutable` and `type` 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
Expand All @@ -47,6 +67,9 @@ Language changes
* `@.` 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]).

Breaking changes
----------------

Expand Down Expand Up @@ -260,10 +283,17 @@ Library improvements

* `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 the `macroexpand` function ([#18660]).

* Introduced a wrapper type for lazy complex conjugation of arrays, `ConjArray`.
Currently, it is used by default for the new `RowVector` type only, and
enforces that both `transpose(vec)` and `ctranspose(vec)` are views not copies ([#20047]).

Compiler/Runtime improvements
-----------------------------

Expand Down Expand Up @@ -358,6 +388,7 @@ Deprecated or removed
[#19787]: https://github.com/JuliaLang/julia/issues/19787
[#19800]: https://github.com/JuliaLang/julia/issues/19800
[#19841]: https://github.com/JuliaLang/julia/issues/19841
[#19900]: https://github.com/JuliaLang/julia/issues/19900
[#19903]: https://github.com/JuliaLang/julia/issues/19903
[#19919]: https://github.com/JuliaLang/julia/issues/19919
[#19944]: https://github.com/JuliaLang/julia/issues/19944
Expand Down
8 changes: 4 additions & 4 deletions base/Enums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export Enum, @enum

function basetype end

abstract Enum{T<:Integer}
abstract type Enum{T<:Integer} end

Base.convert{T<:Integer}(::Type{Integer}, x::Enum{T}) = bitcast(T, x)
Base.convert{T<:Integer,T2<:Integer}(::Type{T}, x::Enum{T2}) = convert(T, bitcast(T2, x))
Expand Down Expand Up @@ -45,7 +45,7 @@ julia> f(apple)
"I'm a Fruit with value: 1"
```
`BaseType`, which defaults to `Int32`, must be a bitstype subtype of Integer. Member values can be converted between
`BaseType`, which defaults to `Int32`, must be a primitive subtype of Integer. Member values can be converted between
the enum type and `BaseType`. `read` and `write` perform these conversions automatically.
"""
macro enum(T,syms...)
Expand All @@ -58,7 +58,7 @@ macro enum(T,syms...)
typename = T.args[1]
basetype = eval(current_module(),T.args[2])
if !isa(basetype, DataType) || !(basetype <: Integer) || !isbits(basetype)
throw(ArgumentError("invalid base type for Enum $typename, $T=::$basetype; base type must be an integer bitstype"))
throw(ArgumentError("invalid base type for Enum $typename, $T=::$basetype; base type must be an integer primitive type"))
end
elseif !isa(T,Symbol)
throw(ArgumentError("invalid type expression for enum $T"))
Expand Down Expand Up @@ -103,7 +103,7 @@ macro enum(T,syms...)
end
blk = quote
# enum definition
Base.@__doc__(bitstype $(sizeof(basetype) * 8) $(esc(typename)) <: Enum{$(basetype)})
Base.@__doc__(primitive type $(esc(typename)) <: Enum{$(basetype)} $(sizeof(basetype) * 8) end)
function Base.convert(::Type{$(esc(typename))}, x::Integer)
$(membershiptest(:x, values)) || enum_argument_error($(Expr(:quote, typename)), x)
return bitcast($(esc(typename)), convert($(basetype), x))
Expand Down
45 changes: 23 additions & 22 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import ..Terminals: raw!, width, height, cmove, getX,

import Base: ensureroom, peek, show, AnyDict

abstract TextInterface
abstract ModeState
abstract type TextInterface end
abstract type ModeState end

export run_interface, Prompt, ModalInterface, transition, reset_state, edit_insert, keymap

immutable ModalInterface <: TextInterface
struct ModalInterface <: TextInterface
modes
end

type MIState
mutable struct MIState
interface::ModalInterface
current_mode
aborted::Bool
Expand All @@ -33,7 +33,7 @@ function show(io::IO, s::MIState)
print(io, "MI State (", s.current_mode, " active)")
end

type Prompt <: TextInterface
mutable struct Prompt <: TextInterface
prompt
# A string or function to be printed before the prompt. May not change the length of the prompt.
# This may be used for changing the color, issuing other terminal escape codes, etc.
Expand All @@ -51,12 +51,12 @@ end

show(io::IO, x::Prompt) = show(io, string("Prompt(\"", x.prompt, "\",...)"))

immutable InputAreaState
struct InputAreaState
num_rows::Int64
curs_row::Int64
end

type PromptState <: ModeState
mutable struct PromptState <: ModeState
terminal
p::Prompt
input_buffer::IOBuffer
Expand All @@ -74,13 +74,13 @@ function input_string_newlines_aftercursor(s::PromptState)
return count(c->(c == '\n'), rest)
end

abstract HistoryProvider
abstract CompletionProvider
abstract type HistoryProvider end
abstract type CompletionProvider end

type EmptyCompletionProvider <: CompletionProvider
mutable struct EmptyCompletionProvider <: CompletionProvider
end

type EmptyHistoryProvider <: HistoryProvider
mutable struct EmptyHistoryProvider <: HistoryProvider
end

reset_state(::EmptyHistoryProvider) = nothing
Expand Down Expand Up @@ -430,7 +430,7 @@ end

# splice! for IOBuffer: convert from 0-indexed positions, update the size,
# and keep the cursor position stable with the text
function splice_buffer!{T<:Integer}(buf::IOBuffer, r::UnitRange{T}, ins::AbstractString = "")
function splice_buffer!(buf::IOBuffer, r::UnitRange{<:Integer}, ins::AbstractString = "")
pos = position(buf)
if !isempty(r) && pos in r
seek(buf, first(r))
Expand Down Expand Up @@ -712,7 +712,7 @@ end
# Redirect a key as if `seq` had been the keysequence instead in a lazy fashion.
# This is different from the default eager redirect, which only looks at the current and lower
# layers of the stack.
immutable KeyAlias
struct KeyAlias
seq::String
KeyAlias(seq) = new(normalize_key(seq))
end
Expand Down Expand Up @@ -911,7 +911,7 @@ function validate_keymap(keymap)
end
end

function keymap{D<:Dict}(keymaps::Array{D})
function keymap(keymaps::Array{<:Dict})
# keymaps is a vector of prioritized keymaps, with highest priority first
ret = keymap_unify(map(normalize_keys, reverse(keymaps)))
validate_keymap(ret)
Expand Down Expand Up @@ -966,7 +966,7 @@ function write_response_buffer(s::PromptState, data)
refresh_line(s)
end

type SearchState <: ModeState
mutable struct SearchState <: ModeState
terminal
histprompt
#rsearch (true) or ssearch (false)
Expand Down Expand Up @@ -1010,17 +1010,17 @@ function reset_state(s::SearchState)
reset_state(s.histprompt.hp)
end

type HistoryPrompt{T<:HistoryProvider} <: TextInterface
mutable struct HistoryPrompt{T<:HistoryProvider} <: TextInterface
hp::T
complete
keymap_dict::Dict{Char,Any}
HistoryPrompt(hp) = new(hp, EmptyCompletionProvider())
HistoryPrompt{T}(hp) where T<:HistoryProvider = new(hp, EmptyCompletionProvider())
end

HistoryPrompt{T<:HistoryProvider}(hp::T) = HistoryPrompt{T}(hp)
HistoryPrompt(hp::T) where T<:HistoryProvider = HistoryPrompt{T}(hp)
init_state(terminal, p::HistoryPrompt) = SearchState(terminal, p, true, IOBuffer(), IOBuffer())

type PrefixSearchState <: ModeState
mutable struct PrefixSearchState <: ModeState
terminal
histprompt
prefix::String
Expand Down Expand Up @@ -1049,15 +1049,16 @@ input_string(s::PrefixSearchState) = String(s.response_buffer)

# a meta-prompt that presents itself as parent_prompt, but which has an independent keymap
# for prefix searching
type PrefixHistoryPrompt{T<:HistoryProvider} <: TextInterface
mutable struct PrefixHistoryPrompt{T<:HistoryProvider} <: TextInterface
hp::T
parent_prompt::Prompt
complete
keymap_dict::Dict{Char,Any}
PrefixHistoryPrompt(hp, parent_prompt) = new(hp, parent_prompt, EmptyCompletionProvider())
PrefixHistoryPrompt{T}(hp, parent_prompt) where T<:HistoryProvider =
new(hp, parent_prompt, EmptyCompletionProvider())
end

PrefixHistoryPrompt{T<:HistoryProvider}(hp::T, parent_prompt) = PrefixHistoryPrompt{T}(hp, parent_prompt)
PrefixHistoryPrompt(hp::T, parent_prompt) where T<:HistoryProvider = PrefixHistoryPrompt{T}(hp, parent_prompt)
init_state(terminal, p::PrefixHistoryPrompt) = PrefixSearchState(terminal, p, "", IOBuffer())

write_prompt(terminal, s::PrefixSearchState) = write_prompt(terminal, s.histprompt.parent_prompt)
Expand Down
26 changes: 13 additions & 13 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import ..LineEdit:
accept_result,
terminal

abstract AbstractREPL
abstract type AbstractREPL end

answer_color(::AbstractREPL) = ""

const JULIA_PROMPT = "julia> "

type REPLBackend
mutable struct REPLBackend
"channel for AST"
repl_channel::Channel
"channel for results: (value, nothing) or (error, backtrace)"
Expand Down Expand Up @@ -110,7 +110,7 @@ function ip_matches_func(ip, func::Symbol)
return false
end

immutable REPLDisplay{R<:AbstractREPL} <: Display
struct REPLDisplay{R<:AbstractREPL} <: Display
repl::R
end

Expand Down Expand Up @@ -167,7 +167,7 @@ function print_response(errio::IO, val::ANY, bt, show_value::Bool, have_color::B
end

# A reference to a backend
immutable REPLBackendRef
struct REPLBackendRef
repl_channel::Channel
response_channel::Channel
end
Expand All @@ -183,7 +183,7 @@ end

## BasicREPL ##

type BasicREPL <: AbstractREPL
mutable struct BasicREPL <: AbstractREPL
terminal::TextTerminal
waserror::Bool
BasicREPL(t) = new(t,false)
Expand Down Expand Up @@ -241,7 +241,7 @@ end

## LineEditREPL ##

type LineEditREPL <: AbstractREPL
mutable struct LineEditREPL <: AbstractREPL
t::TextTerminal
hascolor::Bool
prompt_color::String
Expand Down Expand Up @@ -275,11 +275,11 @@ LineEditREPL(t::TextTerminal, envcolors = false) = LineEditREPL(t,
Base.text_colors[:yellow],
false, false, false, envcolors)

type REPLCompletionProvider <: CompletionProvider; end
mutable struct REPLCompletionProvider <: CompletionProvider; end

type ShellCompletionProvider <: CompletionProvider; end
mutable struct ShellCompletionProvider <: CompletionProvider; end

immutable LatexCompletions <: CompletionProvider; end
struct LatexCompletions <: CompletionProvider; end

beforecursor(buf::IOBuffer) = String(buf.data[1:buf.ptr-1])

Expand All @@ -306,7 +306,7 @@ function complete_line(c::LatexCompletions, s)
end


type REPLHistoryProvider <: HistoryProvider
mutable struct REPLHistoryProvider <: HistoryProvider
history::Array{String,1}
history_file
start_idx::Int
Expand Down Expand Up @@ -633,7 +633,7 @@ function respond(f, repl, main; pass_empty = false)
line = String(take!(buf))
if !isempty(line) || pass_empty
reset(repl)
val, bt = send_to_backend(f(line), backend(repl))
val, bt = send_to_backend(eval(:(($f)($line))), backend(repl))
if !ends_with_semicolon(line) || bt !== nothing
print_response(repl, val, bt, true, Base.have_color)
end
Expand Down Expand Up @@ -742,7 +742,7 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
# and pass into Base.repl_cmd for processing (handles `ls` and `cd`
# special)
on_done = respond(repl, julia_prompt) do line
Expr(:call, :(Base.repl_cmd), macroexpand(Expr(:macrocall, Symbol("@cmd"),line)), outstream(repl))
Expr(:call, :(Base.repl_cmd), Cmd(Base.shell_split(line)), outstream(repl))
end)


Expand Down Expand Up @@ -945,7 +945,7 @@ end

## StreamREPL ##

type StreamREPL <: AbstractREPL
mutable struct StreamREPL <: AbstractREPL
stream::IO
prompt_color::String
input_color::String
Expand Down
9 changes: 5 additions & 4 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ end

function complete_keyword(s::String)
const sorted_keywords = [
"abstract", "baremodule", "begin", "bitstype", "break", "catch", "ccall",
"abstract type", "baremodule", "begin", "break", "catch", "ccall",
"const", "continue", "do", "else", "elseif", "end", "export", "false",
"finally", "for", "function", "global", "if", "immutable", "import",
"importall", "let", "local", "macro", "module", "quote", "return",
"true", "try", "type", "typealias", "using", "while"]
"finally", "for", "function", "global", "if", "import",
"importall", "let", "local", "macro", "module", "mutable struct",
"primitive type", "quote", "return", "struct",
"true", "try", "typealias", "using", "while"]
r = searchsorted(sorted_keywords, s)
i = first(r)
n = length(sorted_keywords)
Expand Down
Loading

0 comments on commit 3159acc

Please sign in to comment.