Skip to content

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

Merged
JeffBezanson merged 1 commit into
JuliaLang:masterfrom
mschauer:sizenumber
May 24, 2016
Merged

Add the corresponding iterator trait to size(::Number) = ()#16444
JeffBezanson merged 1 commit into
JuliaLang:masterfrom
mschauer:sizenumber

Conversation

@mschauer
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
Author

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

@mschauer
Copy link
Copy Markdown
Author

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

@stevengj
Copy link
Copy Markdown
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
Copy Markdown
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