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

Add the corresponding iterator trait to size(::Number) = () #16444

Merged
merged 1 commit into from
May 24, 2016

Conversation

mschauer
Copy link
Contributor

@mschauer mschauer commented May 19, 2016

This makes numbers well behaved with the product iterator and with collect: For example now

size(collect(1)) == size(1)

and after merging #16437 thanks to #15431

size(A[1:3,1,1:3]) == size(Base.product(1:3,1,1:3))

for an array A.

@tkelman
Copy link
Contributor

tkelman commented May 19, 2016

There's a bit of a desire to make numbers not iterable in which case this is not meaningful, ref #7903

@mschauer
Copy link
Contributor Author

I know, I did not want to touch that subject, it is just the right thing for the current situation.

@mschauer
Copy link
Contributor Author

PS: I think now that this definition takes a bit of the pressure away to proceed with #7903.

@stevengj
Copy link
Member

Regardless of whether numbers are iterable, they have to work with broadcast so that you can do things like broadcast(atan2, y, 0.3), so they have to have a size.

In which case it makes sense for them to have the corresponding trait?

(And, in fact, the broadcast case makes me want to re-think the whole "numbers should not be iterable" argument.)

@mschauer
Copy link
Contributor Author

@stevengj Yes, exactly. I just wrote a similar statement over there in 7903.

@JeffBezanson JeffBezanson merged commit 5474db0 into JuliaLang:master May 24, 2016
@mschauer mschauer deleted the sizenumber branch May 24, 2016 18:13
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.

4 participants