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 missing documentation for ArrayLiteral.reduce with memo #8379

Merged
merged 1 commit into from Oct 31, 2019

Conversation

@jan-zajic
Copy link
Contributor

jan-zajic commented Oct 25, 2019

Hi, i found while writing macros that ArrayLiteral don't have reduce method that would allow me to pass initial value. Until i try it, and voilà, it worked. So i look into the spec and there's even a test for it. So it's only missing in generated docs here: https://crystal-lang.org/api/Crystal/Macros.html. So i add it to the definition. As bonus i add test similar to Enumerable, see my other PR #8378.

Related to #8377.

@@ -634,6 +634,10 @@ module Crystal::Macros
def reduce(&block) : ASTNode
end

# Similar to `Enumerable#reduce`
def reduce(memo : ASTNode, &block) : ASTNode

This comment has been minimized.

Copy link
@j8r

j8r Oct 25, 2019

Contributor
Suggested change
def reduce(memo : ASTNode, &block) : ASTNode
def reduce(memo : ASTNode, &) : ASTNode

The new syntax for non-captured blocks can now be used.

This comment has been minimized.

Copy link
@straight-shoota

straight-shoota Oct 25, 2019

Member

The thing is, this makes it now different from the existing #reduce signature. It's probably better to stay with &block for both of them.

We should have a global run to replace all uncaptured &block arguments with &. But it's safer to do this after 0.32.0 is released so it still compiles with pre 0.31.0 compiler. (Not super important, but there is no hurry either)

This comment has been minimized.

Copy link
@jan-zajic

jan-zajic Oct 25, 2019

Author Contributor

ok guys, i changed it there and back again, no problem .. Please just make some consensus.

@jan-zajic jan-zajic force-pushed the jan-zajic:feature/macroReduce branch from ec2adf0 to cd50ac6 Oct 25, 2019
@jan-zajic jan-zajic force-pushed the jan-zajic:feature/macroReduce branch from cd50ac6 to efe69f7 Oct 25, 2019
@RX14
RX14 approved these changes Oct 31, 2019
@RX14 RX14 merged commit f9a4a14 into crystal-lang:master Oct 31, 2019
6 checks passed
6 checks passed
ci/circleci: check_format Your tests passed on CircleCI!
Details
ci/circleci: test_darwin Your tests passed on CircleCI!
Details
ci/circleci: test_linux Your tests passed on CircleCI!
Details
ci/circleci: test_linux32_std Your tests passed on CircleCI!
Details
ci/circleci: test_preview_mt Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@RX14 RX14 added this to the 0.32.0 milestone Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.