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

Express reshape to a certain dimensionality as conversion instead? #23821

Open
mbauman opened this issue Sep 22, 2017 · 1 comment
Open

Express reshape to a certain dimensionality as conversion instead? #23821

mbauman opened this issue Sep 22, 2017 · 1 comment
Labels
arrays [a, r, r, a, y, s] speculative Whether the change will be implemented is speculative

Comments

@mbauman
Copy link
Member

mbauman commented Sep 22, 2017

We've slowly been converging on the final semantics of our post-#4774 arrays. We've nailed down equality (dimensions are significant in terms of equality), and our indexing behaviors post-#14770 have a nice set of rules about how trailing singletons behave with respect to trailing dimensions:

  • You're allowed to specify fewer indices than there are dimensions so long as all omitted dimensions are 1.
  • You're allowed to specify more indices than there are dimensions so long as all extra indices are 1.

I think this could dovetail quite nicely with conversion — would could allow convert(AbstractArray{<:Any, N}, A) to simply add or remove trailing singleton dimensions. In fact, I think that's a slightly better spelling of this behavior than reshape(A, Val(N)).

@mbauman mbauman added arrays [a, r, r, a, y, s] speculative Whether the change will be implemented is speculative labels Sep 22, 2017
@timholy
Copy link
Member

timholy commented Sep 25, 2017

👍 I think formerly one would have had to manually allocate a TypeVar for this syntax, but with the new type system it's much prettier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] speculative Whether the change will be implemented is speculative
Projects
None yet
Development

No branches or pull requests

2 participants