-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
string() not vectorized like other small caps type conversions #8389
Comments
This is exhibit A for why "vectorization" is so incredibly awful. There isn't really any such thing as a "small caps type conversion". There is just a set of functions with that kind of behavior. |
This is the best argument against vectorization that I've seen in a while. |
Yeah, but then let's just make More seriously, the debate around vectorization is always the same: there's a feeling that vectorization is evil, and yet many vectorized functions are present and used in Julia. Either they should be consistent, or they should not exist.
I had the impression that in #1470 people tried finding a rule for them, precisely because currently it's not very clear. |
In general, numerical functions are vectorized. No string functions are. This is quite consistent already. |
FWIW, I wish we didn't have any "small caps type conversion" functions. |
Wanting to increase consistency points in only one direction: fewer vectorized functions. You can't get more consistency by picking a few more functions to vectorize, because it is not clear where to stop that process. I would love to remove most uses of vectorization, such as I would also prefer to remove |
Personally, I think it's really helpful to distinguish functions that necessarily apply to vectors (like One argument in defense of |
I'd love that. Then we could use |
@JeffBezanson: The power to kill vectorization forever is in your hands. Just make |
I totally agree. |
Why not:
|
Let's pretend that we didn't have the now-widely-regretted space sensitivity in array context. Then there are a lot of things we could do. |
That's an interesting idea. Or if you like punctuation, |
What about |
That's nice. |
+1 |
Btw, would that call map or broadcast? |
Should I plan on this possibility? Revising some things in StrPack right now where this comes up; I'll change them over to |
|
👍👍 for fewer vectorized functions and more emphasis on higher order functions like A high precedence binary x as Vector{Int} Taking that further, if we had a unary version like: function as(T::Type)
return x -> x as T
end And used Stefan's syntax for map we could write |
Some other languages already have a syntax for "map", e.g. "/@" in -erik On Wed, Sep 17, 2014 at 2:01 PM, Stefan Karpinski [email protected]
Erik Schnetter [email protected] |
I don't think there's much to be said in favor of |
+1 to I've also been a previous advocate for the |
I find the |
I like |
I like |
That is rather a significant issue. |
|
The other way this could work is to do something like we do for If we do go down the path of mapping over only the first argument, I imagine the |
For multiargument functions, I feel like the right approach is to improve Julia's ability to define closures so that we can do more currying. |
@johnmyleswhite: Which behavior for multi argument functions are you proposing? I think that it would be most consistent if all arguments are treated equally. |
I can see three solutions:
But we need real use cases to decide what's the most useful definition. FWIW, there's a list of currently vectorized functions in the manual: http://docs.julialang.org/en/release-0.3/manual/arrays/#vectorized-operators-and-functions |
Another possible syntax: |
Wait that reads like type constructor on vector. e.g. a = {1,2,3}
Int[ a... ] So do we still keep the |
@nalimilan: Using @tonyhffong: Yes, that is a problematic ambiguity, since they have different semantics. We would have to deprecate that syntax, which I'm not so sure is a good idea. |
I find the |
To resolve the issue of @tonyhffong, what if |
I'd find it more consistent if string returned what is currently
[string(x) for x in 0:2]
. And it seems to me the latter operation is much more common than expecting"[0,1,2]"
, which is useful only in very special contexts. Maybe call itdeparse
,stringrep
or something like that? Or simply use theString
constructor, which by definition must return aString
object, not anArray{<:String}
?This is related to #1470.
The text was updated successfully, but these errors were encountered: