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

Remove ambiguity in input/limits comparison example #18

Merged
merged 1 commit into from Dec 14, 2018

Conversation

Projects
None yet
3 participants
@paultcochrane
Copy link
Contributor

paultcochrane commented Dec 13, 2018

As mentioned in GitHub issue #10, the input/limits comparison example in
the documentation is ambiguous; it could be interpreted as "compare each
element of @input with each element of @limits and return the all
junction of the comparisons". However this isn't the case, for instance:

use strict;
use warnings;

use Syntax::Keyword::Junction qw( all );

my @input = (1, 2, 3, 4, 5, 6);
my @limits = (4, 4, 4, 4, 4, 4);

if (all(@input) <= scalar @limits) {
    print "all input less than or equal to limits\n";
}
else {
    print "not all input less than or equal to limits\n";
}

prints "all input less than or equal to limits", but the last two
elements of the @input array are greater than the limits. However,
the input elements are all less than or equal to the length of the
@limits array. If one reduces the length of the @limits array, then
the code above prints "not all input less than or equal to limits".
This is the same behaviour as in Perl6 (from the REPL):

> all(1, 2, 3, 4, 5, 6) <= (4, 4, 4, 4, 4, 4)
all(True, True, True, True, True, True)
> all(1, 2, 3, 4, 5, 6) <= (4, 4, 4, 4, 4)
all(True, True, True, True, True, False)

Consequently, adding the scalar keyword in the example makes this
behaviour more obvious.

This PR would fix the issue raised in #10.

Remove ambiguity in input/limits comparison example
As mentioned in GitHub issue #10, the input/limits comparison example in
the documentation is ambiguous; it could be interpreted as "compare each
element of `@input` with each element of `@limits` and return the `all`
junction of the comparisons".  However this isn't the case, for instance:

```
use strict;
use warnings;

use Syntax::Keyword::Junction qw( all );

my @input = (1, 2, 3, 4, 5, 6);
my @limits = (4, 4, 4, 4, 4, 4);

if (all(@input) <= scalar @limits) {
    print "all input less than or equal to limits\n";
}
else {
    print "not all input less than or equal to limits\n";
}
```

prints "all input less than or equal to limits", but the last two
elements of the `@input` array are greater than the limits.  However,
the input elements are all less than or equal to the length of the
`@limits` array.  If one reduces the length of the `@limits` array, then
the code above prints "not all input less than or equal to limits".
This is the same behaviour as in Perl6 (from the REPL):

```
> all(1, 2, 3, 4, 5, 6) <= (4, 4, 4, 4, 4, 4)
all(True, True, True, True, True, True)
> all(1, 2, 3, 4, 5, 6) <= (4, 4, 4, 4, 4)
all(True, True, True, True, True, False)
```

Consequently, adding the `scalar` keyword in the example makes this
behaviour more obvious.
@coveralls

This comment has been minimized.

Copy link

coveralls commented Dec 13, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling dcaecbe on paultcochrane:pr/fix-ambiguous-example into d8ea8e8 on frioux:master.

2 similar comments
@coveralls

This comment has been minimized.

Copy link

coveralls commented Dec 13, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling dcaecbe on paultcochrane:pr/fix-ambiguous-example into d8ea8e8 on frioux:master.

@coveralls

This comment has been minimized.

Copy link

coveralls commented Dec 13, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling dcaecbe on paultcochrane:pr/fix-ambiguous-example into d8ea8e8 on frioux:master.

@frioux frioux merged commit 35a16bc into frioux:master Dec 14, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 100.0%
Details

@paultcochrane paultcochrane deleted the paultcochrane:pr/fix-ambiguous-example branch Dec 14, 2018

@paultcochrane

This comment has been minimized.

Copy link
Contributor

paultcochrane commented Dec 16, 2018

@frioux: I think I've managed to submit a patch for all the things I thought I could help out with. Is there anything else you'd like me to do or that you'd like help with?

@frioux

This comment has been minimized.

Copy link
Owner

frioux commented Dec 16, 2018

@paultcochrane not especially; would you like to release a new version?

@paultcochrane

This comment has been minimized.

Copy link
Contributor

paultcochrane commented Dec 16, 2018

@frioux it's probably easier if you cut a release; however I could update the Changes file before you do that, if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment