Skip to content

(PUP-2755) Move iterative functions to new api#2765

Merged
zaphod42 merged 17 commits intopuppetlabs:masterfrom
hlindberg:PUP-2755_move-iterative-functions-to-new-api
Jun 17, 2014
Merged

(PUP-2755) Move iterative functions to new api#2765
zaphod42 merged 17 commits intopuppetlabs:masterfrom
hlindberg:PUP-2755_move-iterative-functions-to-new-api

Conversation

@hlindberg
Copy link
Contributor

This moves the iterative functions each, map, reduce, filter, and slice to the new function.
A utility module was added for shared behavior (included in the functions).

This also removes the function stubs for old / renamed iterative functions as these stubs have played out
their role, and it seemed pointless to move them to the new API.

@puppetcla
Copy link

CLA signed by all contributors.

These functions are just stubs that raises an error, and they are
no longer needed.
This moves all the iterative functions to the 4x function API.
Functions are now simpler to read. A shared utility module
was created for repeated asserts.

While testing it was clear that it is difficult to use
Puppet.lookup(:loaders), and the evaluator was changed to get the
loaders via the compiler instead.

The evaluator tests are changed to make use of the simplified
handling of the loaders.

The tests for the functions that have moved, were also moved, but
are unchanged in what they test.
This adds tests that local and match scope handling is corrent
and does not leak variable bindings.
This fixes merge issues that were not automatically done due to files
being moved and changed structurally.

The support for captures_rest was lost. This is now reinstated in
the shared IterativeSupport module and in reduce and slice where the
semantics of "serving_size" are slightly different.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed (removed)

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to specify the signature for the callable? Something like Callable[Object, 1, 2] I think would do the trick. Then it can probably get rid of the assertion of the serving size and simply work from the defined signature.

Same comment applies to the other functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Turns out that using a signature of Callable[Object, 1, 2] doesn't work because of the support for using captures rest arguments. Specifying |*$x| { ... } as the block results in a signature of Callable[Object] which isn't assignable to Callable[Object, 1, 2]. If we widened Callable[Object, 1, 2] to be able to accept Callable[Object] then it would just end up at Callable[Object], which is the default for required_block_param anyway and all of the checks would need to be put back in.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, this is a bit more of a discussion than I want to have here. I've opened PUP-2794 to track it. I think we should drop the special support for |*$x|, however.

@zaphod42 zaphod42 merged commit 8d56057 into puppetlabs:master Jun 17, 2014
@hlindberg hlindberg deleted the PUP-2755_move-iterative-functions-to-new-api branch September 16, 2017 08:34
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.

3 participants