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

Implement no-copy subarray iteration (Implements #3386) #4584

Merged
merged 3 commits into from Apr 19, 2018
Merged

Implement no-copy subarray iteration (Implements #3386) #4584

merged 3 commits into from Apr 19, 2018

Conversation

cjgajard
Copy link
Contributor

Since I deleted my previous fork I need to PR again.
This PR closes #3390.

# ```text
# b -- c -- d --
# ```
def each(*, within range : Range(Int, Int))
Copy link
Member

@oprypin oprypin Jun 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like requiring within:. Even the example doesn't have it, so it's broken as far as I see 😛

Copy link
Contributor Author

@cjgajard cjgajard Jun 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for checking, the example is broken. The start/count overload also use required named-arguments, I think (for consistency) changing the example should be enough

@akzhan
Copy link
Contributor

akzhan commented Jun 18, 2017

LGTM

@sdogruyol
Copy link
Member

@cjgajard this looks good 👍 Are you around to fix the minor issues?

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why force named parameters?

@RX14
Copy link
Contributor

RX14 commented Apr 19, 2018

They should at least be forced for start and count, and I don't mind the range being a forced named parameter too. I like the named params

@RX14 RX14 merged commit 74cf7c4 into crystal-lang:master Apr 19, 2018
@RX14 RX14 added this to the Next milestone Apr 19, 2018
@yxhuvud
Copy link
Contributor

yxhuvud commented Apr 19, 2018

@RX14 A better question is why count is mandatory. Default could be to iterate to end.

@RX14
Copy link
Contributor

RX14 commented Apr 19, 2018

You could make it default to -1... I don't really care either way. It's a moot point.

# 2 -- 3 --
# ```
def each_index(*, start : Int, count : Int)
raise ArgumentError.new "negative count: #{count}" if count < 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, Title cased Exception messages, please.

@cjgajard cjgajard deleted the feature/nocopy_subarray_each branch April 20, 2018 10:55
chris-huxtable pushed a commit to chris-huxtable/crystal that referenced this pull request Jun 6, 2018
…rystal-lang#4584)

* Implement no-copy subarray iteration

* Fix example for Indexable#each(*, within)

* Fix Indexable#each_index(*, start, count) example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants