Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use call for string to numeric conversion #10599

Closed
wants to merge 1 commit into from
Closed

Conversation

simonbyrne
Copy link
Contributor

Fixes issue #10594.

@@ -409,12 +395,7 @@ for (f,t) in ((:int, Int), (:int8, Int8), (:int16, Int16), (:int32, Int32
(:int64, Int64), (:int128, Int128), (:uint, UInt), (:uint8, UInt8),
(:uint16, UInt16), (:uint32, UInt32), (:uint64, UInt64), (:uint128,UInt128))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this list get Float32 and Float64 added to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garborg
Copy link
Contributor

garborg commented Mar 25, 2015

I don't want to rush any decisions, but this would be great to resolve one way or the other before packages like JuliaParser.jl and LibExpat.jl make decisions about whether to keep exporting a parse that doesn't extend Base.parse.

@JeffBezanson
Copy link
Member

I guess this is ok. IIRC, our thinking used to be that for something as simple as a number, construction and conversion should be the same thing, and that parsing should be done explicitly since it is slow.

@stevengj
Copy link
Member

Looks good to me. (A perfect example of where T(x) should be defined but not convert(T, x), because we never want this conversion to happen implicitly.)

@stevengj
Copy link
Member

In this case, why do we need parse{T<:Number}(T, x)?

@JeffBezanson
Copy link
Member

Yes, I think that's a bit of a problem. If we have both, it's not clear which one to call or define. If we use only constructors, then the interface to parsing is construction. However this doesn't make sense for all types. For example List("(1 2)") could construct a list of one string, but parse(List, "(1 2)") would construct a list of two integers.

@simonbyrne simonbyrne changed the title Use call for integer to numeric conversion Use call for string to numeric conversion Apr 8, 2015
@simonbyrne simonbyrne closed this Apr 28, 2015
@simonbyrne simonbyrne deleted the sb/parsefloat branch April 28, 2015 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants