Skip to content

Commit

Permalink
remove {} Any array / dict syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebolewski committed Oct 5, 2014
1 parent 8b708d9 commit c7d0069
Show file tree
Hide file tree
Showing 64 changed files with 527 additions and 517 deletions.
63 changes: 32 additions & 31 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -834,29 +834,30 @@ function keymap{D<:Dict}(keymaps::Array{D})
end

const escape_defaults = merge!(
{char(i) => nothing for i=[1:26, 28:31]}, # Ignore control characters by default
{ # And ignore other escape sequences by default
"\e*" => nothing,
"\e[*" => nothing,
# Also ignore extended escape sequences
# TODO: Support ranges of characters
"\e[1**" => nothing,
"\e[2**" => nothing,
"\e[3**" => nothing,
"\e[4**" => nothing,
"\e[5**" => nothing,
"\e[6**" => nothing,
"\e[1~" => "\e[H",
"\e[4~" => "\e[F",
"\e[7~" => "\e[H",
"\e[8~" => "\e[F",
"\eOA" => "\e[A",
"\eOB" => "\e[B",
"\eOC" => "\e[C",
"\eOD" => "\e[D",
"\eOH" => "\e[H",
"\eOF" => "\e[F",
})
(Any=>Any)[char(i) => nothing for i=[1:26, 28:31]], # Ignore control characters by default
(Any=>Any)[ # And ignore other escape sequences by default
"\e*" => nothing,
"\e[*" => nothing,
# Also ignore extended escape sequences
# TODO: Support ranges of characters
"\e[1**" => nothing,
"\e[2**" => nothing,
"\e[3**" => nothing,
"\e[4**" => nothing,
"\e[5**" => nothing,
"\e[6**" => nothing,
"\e[1~" => "\e[H",
"\e[4~" => "\e[F",
"\e[7~" => "\e[H",
"\e[8~" => "\e[F",
"\eOA" => "\e[A",
"\eOB" => "\e[B",
"\eOC" => "\e[C",
"\eOD" => "\e[D",
"\eOH" => "\e[H",
"\eOF" => "\e[F",
]
)

function write_response_buffer(s::PromptState, data)
offset = s.input_buffer.ptr
Expand Down Expand Up @@ -997,7 +998,7 @@ end

function setup_search_keymap(hp)
p = HistoryPrompt(hp)
pkeymap = {
pkeymap = (Any=>Any)[
"^R" => (s,data,c)->(history_set_backward(data, true); history_next_result(s, data)),
"^S" => (s,data,c)->(history_set_backward(data, false); history_next_result(s, data)),
'\r' => (s,o...)->accept_result(s, p),
Expand Down Expand Up @@ -1066,12 +1067,12 @@ function setup_search_keymap(hp)
edit_insert(data.query_buffer, input); update_display_buffer(s, data)
end,
"*" => (s,data,c)->(edit_insert(data.query_buffer, c); update_display_buffer(s, data))
}
]
p.keymap_func = keymap([pkeymap, escape_defaults])
skeymap = {
skeymap = (Any=>Any)[
"^R" => (s,o...)->(enter_search(s, p, true)),
"^S" => (s,o...)->(enter_search(s, p, false)),
}
]
(p, skeymap)
end

Expand Down Expand Up @@ -1118,7 +1119,7 @@ function commit_line(s)
end

const default_keymap =
{
(Any=>Any)[
# Tab
'\t' => (s,o...)->begin
buf = buffer(s)
Expand Down Expand Up @@ -1226,9 +1227,9 @@ const default_keymap =
edit_insert(s, input)
end,
"^T" => (s,o...)->edit_transpose(s),
}
]

const history_keymap = {
const history_keymap = (Any=>Any)[
"^P" => (s,o...)->(history_prev(s, mode(s).hist)),
"^N" => (s,o...)->(history_next(s, mode(s).hist)),
# Up Arrow
Expand All @@ -1239,7 +1240,7 @@ const history_keymap = {
"\e[5~" => (s,o...)->(history_prev(s, mode(s).hist)),
# Page Down
"\e[6~" => (s,o...)->(history_next(s, mode(s).hist))
}
]

function deactivate(p::Union(Prompt,HistoryPrompt), s::Union(SearchState,PromptState), termbuf)
clear_input_area(termbuf, s)
Expand Down
10 changes: 5 additions & 5 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function eval_user_input(ast::ANY, backend::REPLBackend)
ans = backend.ans
# note: value wrapped in a non-syntax value to avoid evaluating
# possibly-invalid syntax (issue #6763).
eval(Main, :(ans = $({ans})[1]))
eval(Main, :(ans = $(Any[ans])[1]))
value = eval(Main, ast)
backend.ans = value
put!(backend.response_channel, (value, nothing))
Expand Down Expand Up @@ -704,7 +704,7 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
extra_repl_keymap = [extra_repl_keymap]
end

const repl_keymap = {
const repl_keymap = (Any=>Any)[
';' => function (s,o...)
if isempty(s) || position(LineEdit.buffer(s)) == 0
buf = copy(LineEdit.buffer(s))
Expand Down Expand Up @@ -775,14 +775,14 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
end
end
end,
}
]

a = Dict{Any,Any}[hkeymap, repl_keymap, LineEdit.history_keymap, LineEdit.default_keymap, LineEdit.escape_defaults]
prepend!(a, extra_repl_keymap)

julia_prompt.keymap_func = LineEdit.keymap(a)

const mode_keymap = {
const mode_keymap = (Any=>Any)[
'\b' => function (s,o...)
if isempty(s) || position(LineEdit.buffer(s)) == 0
buf = copy(LineEdit.buffer(s))
Expand All @@ -801,7 +801,7 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
transition(s, :reset)
LineEdit.refresh_line(s)
end
}
]

b = Dict{Any,Any}[hkeymap, mode_keymap, LineEdit.history_keymap, LineEdit.default_keymap, LineEdit.escape_defaults]
prepend!(b, extra_repl_keymap)
Expand Down
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ end
##
# generic map on any iterator
function map(f::Callable, iters...)
result = {}
result = []
len = length(iters)
states = [start(iters[idx]) for idx in 1:len]
nxtvals = cell(len)
Expand Down
2 changes: 1 addition & 1 deletion base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function length_checked_equal(args...)
n
end

map(f::Callable, a::Array{Any,1}) = { f(a[i]) for i=1:length(a) }
map(f::Callable, a::Array{Any,1}) = Any[ f(a[i]) for i=1:length(a) ]

macro thunk(ex); :(()->$(esc(ex))); end
macro L_str(s); s; end
Expand Down
8 changes: 4 additions & 4 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const ARGS = UTF8String[]

const text_colors = {
const text_colors = (Any=>Any)[
:black => "\033[1m\033[30m",
:red => "\033[1m\033[31m",
:green => "\033[1m\033[32m",
Expand All @@ -14,7 +14,7 @@ const text_colors = {
:white => "\033[1m\033[37m",
:normal => "\033[0m",
:bold => "\033[1m",
}
]

have_color = false
@unix_only default_color_answer = text_colors[:bold]
Expand Down Expand Up @@ -70,7 +70,7 @@ function repl_hook(input::String)
macroexpand(Expr(:macrocall,symbol("@cmd"),input)))
end

display_error(er) = display_error(er, {})
display_error(er) = display_error(er, [])
function display_error(er, bt)
with_output_color(:red, STDERR) do io
print(io, "ERROR: ")
Expand Down Expand Up @@ -420,7 +420,7 @@ function _start()
ccall(:uv_atexit_hook, Void, ())
end

const atexit_hooks = {}
const atexit_hooks = []

atexit(f::Function) = (unshift!(atexit_hooks, f); nothing)

Expand Down
2 changes: 1 addition & 1 deletion base/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function nextsetpartition(s::AbstractVector, a, b, n, m)
filter!(x->!isempty(x), temp)
end

if isempty(s); return ({s}, ([1], Int[], n, 1)); end
if isempty(s); return ([s], ([1], Int[], n, 1)); end

part = makeparts(s,a,m)

Expand Down
2 changes: 1 addition & 1 deletion base/constants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ convert{T<:Integer}(::Type{Rational{T}}, x::MathConst) = convert(Rational{T}, fl
hash(x::MathConst, h::Uint) = hash(object_id(x), h)

-(x::MathConst) = -float64(x)
for op in {:+, :-, :*, :/, :^}
for op in Symbol[:+, :-, :*, :/, :^]
@eval $op(x::MathConst, y::MathConst) = $op(float64(x),float64(y))
end

Expand Down
4 changes: 2 additions & 2 deletions base/darray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function setindex!(a::Array, s::SubDArray, I::UnitRange{Int}...)
offs = [isa(J[i],Int) ? J[i]-1 : first(J[i])-1 for i=1:n]
@sync begin
for i = 1:length(d.chunks)
K_c = {d.indexes[i]...}
K_c = Any[d.indexes[i]...]
K = [ intersect(J[j],K_c[j]) for j=1:n ]
if !any(isempty, K)
idxs = [ I[j][K[j]-offs[j]] for j=1:n ]
Expand Down Expand Up @@ -302,7 +302,7 @@ map(f::Callable, d::DArray) = DArray(I->map(f, localpart(d)), d)

reduce(f::Function, d::DArray) =
mapreduce(fetch, f,
{ @spawnat p reduce(f, localpart(d)) for p in procs(d) })
Any[ @spawnat p reduce(f, localpart(d)) for p in procs(d) ])


function map!(f::Callable, d::DArray)
Expand Down
4 changes: 2 additions & 2 deletions base/dates/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ duplicates(slots) = any(map(x->count(y->x.period==y.period,slots),slots) .> 1)

function DateFormat(f::String,locale::String="english")
slots = Slot[]
trans = {}
trans = []
begtran = match(r"^.*?(?=[ymuUdHMSsEe])",f).match
ss = split(f,r"^.*?(?=[ymuUdHMSsEe])")
s = split(begtran == "" ? ss[1] : ss[2],r"[^ymuUdHMSsEe]+|(?<=([ymuUdHMSsEe])(?!\1))")
Expand Down Expand Up @@ -182,4 +182,4 @@ function format(y::AbstractArray{Date},df::DateFormat=ISODateFormat)
end
function format(y::AbstractArray{DateTime},df::DateFormat=ISODateTimeFormat)
return reshape([Dates.format(y[i],df) for i in 1:length(y)], size(y))
end
end
2 changes: 1 addition & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ eval(Sys, :(@deprecate shlib_list dllist))
@deprecate put put!
@deprecate take take!

@deprecate Set(a, b...) Set({a, b...})
@deprecate Set(a, b...) Set([a, b...])
# for a bit of backwards compatibility
IntSet(xs::Integer...) = (s=IntSet(); for a in xs; push!(s,a); end; s)
Set{T<:Number}(xs::T...) = Set{T}(xs)
Expand Down
2 changes: 1 addition & 1 deletion base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ _inline(arg) = arg

## some macro utilities ##

find_vars(e) = find_vars(e, {})
find_vars(e) = find_vars(e, [])
function find_vars(e, lst)
if isa(e,Symbol)
if current_module()===Main && isdefined(e)
Expand Down
6 changes: 3 additions & 3 deletions base/help.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ function init_help()
mfunc = func
end
if !haskey(FUNCTION_DICT, mfunc)
FUNCTION_DICT[mfunc] = {}
FUNCTION_DICT[mfunc] = []
end
push!(FUNCTION_DICT[mfunc], desc)
if !haskey(MODULE_DICT, func)
MODULE_DICT[func] = {}
MODULE_DICT[func] = []
end
if !in(mod, MODULE_DICT[func])
push!(MODULE_DICT[func], mod)
Expand Down Expand Up @@ -94,7 +94,7 @@ function help(io::IO, fname::String, obj=0)
found = true
elseif haskey(MODULE_DICT, fname)
allmods = MODULE_DICT[fname]
alldesc = {}
alldesc = []
for mod in allmods
mfname = isempty(mod) ? fname : mod * "." * fname
if isgeneric(obj)
Expand Down
Loading

0 comments on commit c7d0069

Please sign in to comment.