Skip to content

Commit

Permalink
NEWS and doc updates for parse/tryparse
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
JeffBezanson committed Mar 17, 2015
1 parent d76e086 commit 9e1cc7f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
13 changes: 12 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,15 @@ Deprecated or removed
names have been removed. To convert a scalar, use the type name, e.g.
`Int32(x)`. To convert an array to a different element type, use
`Array{T}(x)`, `map(T,x)`, or `round(T,x)`. To parse a string as an integer
or floating-point number, use `parseint` or `parsefloat` ([#1470], [#6211]).
or floating-point number, use `parse` ([#1470], [#6211]).

* Low-level functions from the C library and dynamic linker have been moved to
modules `Libc` and `Libdl`, respectively ([#10328]).

* The functions `parseint`, `parsefloat`, `float32_isvalid`, and `float64_isvalid`
have been replaced by `parse` and `tryparse` with a type argument
([#3631], [#5704], [#9487], [#10543]).

Julia v0.3.0 Release Notes
==========================

Expand Down Expand Up @@ -1070,6 +1074,7 @@ Too numerous to mention.
[#3483]: https://github.com/JuliaLang/julia/issues/3483
[#3523]: https://github.com/JuliaLang/julia/issues/3523
[#3605]: https://github.com/JuliaLang/julia/issues/3605
[#3631]: https://github.com/JuliaLang/julia/issues/3631
[#3649]: https://github.com/JuliaLang/julia/issues/3649
[#3665]: https://github.com/JuliaLang/julia/issues/3665
[#3688]: https://github.com/JuliaLang/julia/issues/3688
Expand Down Expand Up @@ -1158,6 +1163,7 @@ Too numerous to mention.
[#5671]: https://github.com/JuliaLang/julia/issues/5671
[#5677]: https://github.com/JuliaLang/julia/issues/5677
[#5703]: https://github.com/JuliaLang/julia/issues/5703
[#5704]: https://github.com/JuliaLang/julia/issues/5704
[#5726]: https://github.com/JuliaLang/julia/issues/5726
[#5737]: https://github.com/JuliaLang/julia/issues/5737
[#5748]: https://github.com/JuliaLang/julia/issues/5748
Expand Down Expand Up @@ -1278,6 +1284,7 @@ Too numerous to mention.
[#9425]: https://github.com/JuliaLang/julia/issues/9425
[#9434]: https://github.com/JuliaLang/julia/issues/9434
[#9452]: https://github.com/JuliaLang/julia/issues/9452
[#9487]: https://github.com/JuliaLang/julia/issues/9487
[#9569]: https://github.com/JuliaLang/julia/issues/9569
[#9575]: https://github.com/JuliaLang/julia/issues/9575
[#9578]: https://github.com/JuliaLang/julia/issues/9578
Expand All @@ -1295,6 +1302,10 @@ Too numerous to mention.
[#10150]: https://github.com/JuliaLang/julia/issues/10150
[#10180]: https://github.com/JuliaLang/julia/issues/10180
[#10228]: https://github.com/JuliaLang/julia/issues/10228
[#10328]: https://github.com/JuliaLang/julia/issues/10328
[#10332]: https://github.com/JuliaLang/julia/issues/10332
[#10333]: https://github.com/JuliaLang/julia/issues/10333
[#10400]: https://github.com/JuliaLang/julia/issues/10400
[#10446]: https://github.com/JuliaLang/julia/issues/10446
[#10458]: https://github.com/JuliaLang/julia/issues/10458
[#10543]: https://github.com/JuliaLang/julia/issues/10543
2 changes: 1 addition & 1 deletion doc/NEWS-update.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ s = readall(NEWS)
s = s[1:match(r"\[#[0-9]+\]:", s).offset-1];

footnote(n) = "[#$n]: https://github.com/JuliaLang/julia/issues/$n"
N = map(m -> parseint(m.captures[1]), eachmatch(r"\[#([0-9]+)\]", s))
N = map(m -> parse(Int,m.captures[1]), eachmatch(r"\[#([0-9]+)\]", s))
foots = join(map(footnote, sort!(unique(N))), "\n")

open(NEWS, "w") do f
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/conversion-and-promotion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ numbers as strings to be conversions (many dynamic languages will even
perform conversion for you automatically), however Julia does not: even
though some strings can be parsed as numbers, most strings are not valid
representations of numbers, and only a very limited subset of them are.
Therefore in Julia the dedicated ``parseint`` function must be used
Therefore in Julia the dedicated ``parse`` function must be used
to perform this operation, making it more explicit.

Defining New Conversions
Expand Down
10 changes: 5 additions & 5 deletions doc/manual/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,11 @@ Optional Arguments

In many cases, function arguments have sensible default values and therefore
might not need to be passed explicitly in every call. For example, the
library function :func:`parseint(num,base) <parseint>` interprets a string as a number
library function :func:`parse(type,num,base) <parse>` interprets a string as a number
in some base. The ``base`` argument defaults to ``10``. This behavior can be
expressed concisely as::

function parseint(num, base=10)
function parse(type, num, base=10)
###
end

Expand All @@ -437,13 +437,13 @@ specified:

.. doctest::

julia> parseint("12",10)
julia> parse(Int,"12",10)
12

julia> parseint("12",3)
julia> parse(Int,"12",3)
5

julia> parseint("12")
julia> parse(Int,"12")
12

Optional arguments are actually just a convenient syntax for writing
Expand Down
17 changes: 6 additions & 11 deletions doc/stdlib/numbers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ Data Formats

A string giving the literal bit representation of a number.

.. function:: parseint([type], str, [base])
.. function:: parse(type, str, [base])

Parse a string as an integer in the given base (default 10), yielding a number of the specified type (default ``Int``).
Parse a string as a number. If the type is an integer type, then a base can be specified (the default is 10). If the type is a floating point type, the string is parsed as a decimal floating point number.
If the string does not contain a valid number, an error is raised.

.. function:: parsefloat([type], str)
.. function:: tryparse(type, str, [base])

Parse a string as a decimal floating point number, yielding a number of the specified type.
Like ``parse``, but returns a ``Nullable`` of the requested type.
The result will be null if the string does not contain a valid number.

.. function:: big(x)

Expand All @@ -67,13 +69,6 @@ Data Formats
.. function:: unsigned(x) -> Unsigned

Convert a number to an unsigned integer. If the argument is signed, it is reinterpreted as unsigned without checking for negative values.
.. function:: float32_isvalid(x, out::Vector{Float32}) -> Bool

Convert a number or array to ``Float32`` data type, returning true if successful. The result of the conversion is stored in ``out[1]``.

.. function:: float64_isvalid(x, out::Vector{Float64}) -> Bool

Convert a number or array to ``Float64`` data type, returning true if successful. The result of the conversion is stored in ``out[1]``.

.. function:: float(x)

Expand Down

0 comments on commit 9e1cc7f

Please sign in to comment.