From d9495c7af867b93b4cf5b79494ceea04902525a1 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Mon, 4 Apr 2016 10:56:25 +0900 Subject: [PATCH] resolve Warning mismatch by renaming functions --- doc/manual/control-flow.rst | 42 ++++++++++++++++----------------- doc/manual/methods.rst | 12 +++++----- doc/manual/stacktraces.rst | 46 ++++++++++++++++++------------------- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/doc/manual/control-flow.rst b/doc/manual/control-flow.rst index 7b1675f67f5cf..28d86231463a1 100644 --- a/doc/manual/control-flow.rst +++ b/doc/manual/control-flow.rst @@ -128,7 +128,7 @@ So, we could have defined the ``test`` function above as .. doctest:: - julia> function test(x,y) + julia> function test1(x,y) if x < y relation = "less than" elseif x == y @@ -138,7 +138,7 @@ So, we could have defined the ``test`` function above as end println("x is ", relation, " y.") end - test (generic function with 1 method) + test1 (generic function with 1 method) The variable ``relation`` is declared inside the ``if`` block, but used outside. However, when depending on this behavior, make sure all possible @@ -147,7 +147,7 @@ the above function results in a runtime error .. doctest:: - julia> function test(x,y) + julia> function test2(x,y) if x < y relation = "less than" elseif x == y @@ -155,14 +155,14 @@ the above function results in a runtime error end println("x is ", relation, " y.") end - test (generic function with 1 method) + test2 (generic function with 1 method) - julia> test(1,2) + julia> test2(1,2) x is less than y. - julia> test(2,1) + julia> test2(2,1) ERROR: UndefVarError: relation not defined - in test(::Int64, ::Int64) at ./none:7 + in test2(::Int64, ::Int64) at ./none:7 in eval(::Module, ::Any) at ./boot.jl:237 ``if`` blocks also return a value, which may seem unintuitive to users @@ -238,17 +238,17 @@ together: .. doctest:: - julia> test(x, y) = println(x < y ? "x is less than y" : + julia> test4(x, y) = println(x < y ? "x is less than y" : x > y ? "x is greater than y" : "x is equal to y") - test (generic function with 1 method) + test4 (generic function with 1 method) - julia> test(1, 2) + julia> test4(1, 2) x is less than y - julia> test(2, 1) + julia> test4(2, 1) x is greater than y - julia> test(1, 1) + julia> test4(1, 1) x is equal to y To facilitate chaining, the operator associates from right to left. @@ -684,15 +684,15 @@ if the argument is negative: .. doctest:: - julia> f(x) = x>=0 ? exp(-x) : throw(DomainError()) - f (generic function with 1 method) + julia> g(x) = x>=0 ? exp(-x) : throw(DomainError()) + g (generic function with 1 method) - julia> f(1) + julia> g(1) 0.36787944117144233 - julia> f(-1) + julia> g(-1) ERROR: DomainError: - in f(::Int64) at ./none:1 + in g(::Int64) at ./none:1 in eval(::Module, ::Any) at ./boot.jl:237 Note that :exc:`DomainError` without parentheses is not an exception, but a type of @@ -808,17 +808,17 @@ call either the real or complex square root method on demand using .. doctest:: - julia> f(x) = try + julia> h(x) = try sqrt(x) catch sqrt(complex(x, 0)) end - f (generic function with 1 method) + h (generic function with 1 method) - julia> f(1) + julia> h(1) 1.0 - julia> f(-1) + julia> h(-1) 0.0 + 1.0im It is important to note that in real code computing this function, one would diff --git a/doc/manual/methods.rst b/doc/manual/methods.rst index 8013a56c50f1e..e7fb935b2891e 100644 --- a/doc/manual/methods.rst +++ b/doc/manual/methods.rst @@ -418,19 +418,19 @@ the intersection case: .. doctest:: - julia> g(x::Float64, y::Float64) = 2x + 2y; + julia> h(x::Float64, y::Float64) = 2x + 2y; - julia> g(x::Float64, y) = 2x + y; + julia> h(x::Float64, y) = 2x + y; - julia> g(x, y::Float64) = x + 2y; + julia> h(x, y::Float64) = x + 2y; - julia> g(2.0, 3) + julia> h(2.0, 3) 7.0 - julia> g(2, 3.0) + julia> h(2, 3.0) 8.0 - julia> g(2.0, 3.0) + julia> h(2.0, 3.0) 10.0 To suppress Julia's warning, the disambiguating method must be defined diff --git a/doc/manual/stacktraces.rst b/doc/manual/stacktraces.rst index c72943b7d5f8d..fb56df43e72c5 100644 --- a/doc/manual/stacktraces.rst +++ b/doc/manual/stacktraces.rst @@ -118,17 +118,17 @@ helpful in many places, the most obvious application is in error handling and de julia> @noinline bad_function() = undeclared_variable bad_function (generic function with 1 method) - julia> @noinline example() = try + julia> @noinline example1() = try bad_function() catch stacktrace() end - example (generic function with 1 method) + example1 (generic function with 1 method) - julia> example() + julia> example1() ...-element Array{StackFrame,1}: [inlined code] from stacktraces.jl:135 - in example() at none:2 + in example1() at none:2 in eval(::Module, ::Any) at boot.jl:237 [inlined code] from sysimg.jl:11 ... @@ -146,20 +146,20 @@ returns stack information for the context of the most recent exception: .. doctest:: - julia> @noinline bad_function() = undeclared_variable - bad_function (generic function with 1 method) + julia> @noinline bad_function1() = undeclared_variable + bad_function1 (generic function with 1 method) - julia> @noinline example() = try - bad_function() + julia> @noinline example2() = try + bad_function1() catch catch_stacktrace() end - example (generic function with 1 method) + example2 (generic function with 1 method) - julia> example() + julia> example2() ...-element Array{StackFrame,1}: - in bad_function() at none:1 - in example() at none:2 + in bad_function1() at none:1 + in example2() at none:2 in eval(::Module, ::Any) at boot.jl:237 [inlined code] from sysimg.jl:11 ... @@ -168,28 +168,28 @@ Notice that the stack trace now indicates the appropriate line number and the mi .. doctest:: - julia> @noinline child() = error("Whoops!") - child (generic function with 1 method) + julia> @noinline child1() = error("Whoops!") + child1 (generic function with 1 method) - julia> @noinline parent() = child() - parent (generic function with 1 method) + julia> @noinline parent1() = child1() + parent1 (generic function with 1 method) - julia> @noinline function grandparent() + julia> @noinline function grandparent1() try - parent() + parent1() catch err println("ERROR: ", err.msg) catch_stacktrace() end end - grandparent (generic function with 1 method) + grandparent1 (generic function with 1 method) - julia> grandparent() + julia> grandparent1() ERROR: Whoops! ...-element Array{StackFrame,1}: - in child() at none:1 - in parent() at none:1 - in grandparent() at none:3 + in child1() at none:1 + in parent1() at none:1 + in grandparent1() at none:3 in eval(::Module, ::Any) at boot.jl:237 [inlined code] from sysimg.jl:11 ...