Parse in julia 1.0

In julia 0.7, parse( "1+1" ) gives result of the julia parser for that string. On, 1.0, it gives an error. Does this functionality now exist by another name?

2 Likes

That function call gives a deprecation warning in 0.7:

Warning: `parse(str::AbstractString; kwargs...)` is deprecated, use 
`Meta.parse(str; kwargs...)` instead.

It looks like parser functionality was split into Base.parse for parsing of numeric literal strings, and Meta.parse for expression parsing.

julia> Base.parse(Float32, "1.7")
1.7f0

julia> Meta.parse("1 + 1")
:(1 + 1)

julia> eval(ans)
2
9 Likes