I am unsure of the sense in which that constitutes a reason. But it doesnāt matter. The name of the method is slightly non-obvious, but presumably this page will now come up if someone else googles it.
the set has no dimensions (shape), so size is not the right abstraction. length will always give you the number of elements, and for that reason it applies to Set.
Yes, but logically the term ālengthā doesnāt make sense for a set, because, well, sets arenāt the sort of things that have length. So the name ālengthā is not so easy to guess if you donāt already know it. But I did guess it all the same, and posted my answer, so thatās the end of the problem really. Nothing more to see here.
As @pkofod pointed out, length is for the number of element in a collection. Set is a collection, so it has length.
Whether it is intuitive or not is of course subjective, but perhaps as you learn Julia you will find it reasonable. One advantage is that once you learn about length (which comes way before in the docs), you can apply it to all sorts of collections ā it is in this sense that length is said to be generic.
Generic building blocks are key to using Julia efficiently: you can write code that should work for a wider range of collections, regardless of whether they are Sets. Eg
julia> function dont_like_4!(x)
4 ā x && empty!(x)
x
end
dont_like_4! (generic function with 1 method)
julia> dont_like_4!([1,2,3])
3-element Array{Int64,1}:
1
2
3
julia> dont_like_4!(Set([1,2,3]))
Set([2, 3, 1])
julia> dont_like_4!([1,2,3,4])
0-element Array{Int64,1}
julia> dont_like_4!(Set([1,2,3,4]))
Set(Int64[])
Finally, I am curious if you have an alternative suggestion that would be more easily discoverable.
FWIW, you could make a PR that overloads size(s::Set) and returns a better error message that points users to length. Donāt know if this will be accepted though.
No, no, look, youāre all dragging this out way longer than it needs to be. I understand perfectly well that thereās an internal consistency to the naming of methods in any language, and that in this case, the logical choice was ālengthā and not āsizeā. The only problem was that ālengthā was hard to guess, and the documentation was hard to find. (Try googling ājulia setā.)
These problems are solved by the existence of the first two posts in this thread, which will hopefully appear when someone else googles the same question. There is really no need for any further discussion at all.
Matlab does some strange things with the length function; for example, for an array, A, it is equal to max(size(A)).
But they have a numel function which is basically the same as Juliaās length. Iām not sure how discoverable it would be, except for former Matlab users, but it actually makes more sense to me than length.
There are offline docs available for your julia install, which can be accessed by pointing your browser to: file:///abs_path_to_your_julia_install_dir/share/doc/julia/html/en/index.html
(at least on linux :-))
Not sure about emails, but at the bottom of the Discourse web interface thereās a drop down menu, that probably has selected āTrackingā. You can change that to āMutedā.
Perhaps that will stop the emails too. Iām not sure, though, I never keep track of these update emails, they just accumulate in an email folder I never open.
You could also request a moderator to close the thread.
But is this amount of traffic really such an onus?