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

Update declaration of the binarySearch function. #407

Closed
wants to merge 1 commit into from

Conversation

paulnice
Copy link

Problem: Previous declaration wasn't compatible with the tests:

test_binary_search.zig:10:20: error: expected 2 argument(s), found 3
    const actual = binarySearch(i4, 6, &array);
                   ^~~~~~~~~~~~
binary_search.zig:3:5: note: function declared here

Solution: declare the function properly.

Testing: with existing test cases

Problem: Previous declaration wasn't compatible with the tests:
```
test_binary_search.zig:10:20: error: expected 2 argument(s), found 3
    const actual = binarySearch(i4, 6, &array);
                   ^~~~~~~~~~~~
binary_search.zig:3:5: note: function declared here
```
Solution: declare the function properly.

Testing: with existing test cases
Copy link

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this May 26, 2024
@ee7
Copy link
Member

ee7 commented May 26, 2024

Thanks for the PR.

It's intended that the user has to modify the function signature in the solution stub sometimes - I think there's some value in the user adding this themselves. That's why the modified file has the comment:

// Take a look at the tests, you might have to change the function arguments
pub fn binarySearch(target: usize, items: []const usize) ?usize {

But I'm sure this could be a bit awkward or unexpected, since the user gets used to starting out with correct function signatures in previous exercises. In general the track doesn't work like Ziglings, which emphasises fixing broken programs. But I recall that at least the later linked-list exercise stub also doesn't provide complete function signatures.

Rather than merging this PR, I'm leaning towards trying to clarify further (in this file, and/or adding a note to this exercise's docs) that the function signature here needs to be completed. Does that sound good to you? Happy to hear your thoughts on that, or on anything else with the track. Thanks.

@paulnice
Copy link
Author

It is up to you.. I don't read full task explanation usually. Too much text to my taste.
Now I know it's ok to have wrong function declaration. I think it is better to show this case earlier, to get least surprise from the user. Probably in the first, second exercise. It would be like showing game rules for a newbie.

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.

2 participants