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

Inconsistent Argument Order #19314

Closed
miakramer opened this issue Nov 13, 2016 · 2 comments
Closed

Inconsistent Argument Order #19314

miakramer opened this issue Nov 13, 2016 · 2 comments

Comments

@miakramer
Copy link

miakramer commented Nov 13, 2016

Hi,

While using Julia to look at strings, I noticed the ordering for arguments is different for looking at collections/elements vs string/substring. For example, contains uses haystack, needle while in uses item, collection. This behavior is inconsistent and unintuitive. While it makes most sense to me personally to always use smaller, larger, I think it's more important to just be consistent.

I realize this is a big and breaking change but if it's going to be done, sooner is better than later. Perhaps there's some reason for doing it that I'm not aware of, but for reference Python's small in large syntax is very intuitive and consistent; you can use item in collection and string in largerstring, exactly what one would expect, even without looking at the language reference (which one currently has to do with Julia).

This is related to #19186, #10593, #5664. It seems like an overhaul to make argument ordering more intuitive and establishing a Julian guideline for doing so would help adoption of the language by making it easier to learn.

@mbauman
Copy link
Sponsor Member

mbauman commented Nov 13, 2016

You can use in as an infix operator in Julia, too: item in collection works just as you'd expect. That's not true for contains, but when I use it I always read it in infix order to help me remember which argument goes where:

in(item, collection) == item in collection
contains(haystack, needle) # haystack contains needle

@miakramer
Copy link
Author

Ah, thinking about in that way makes sense. Thanks!

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

No branches or pull requests

2 participants