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

binary-search: use equal for all numeric test comparisons #319

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

berquist
Copy link
Contributor

This is more of a question about consistency within a test suite and across all the exercises than anything else. I'll also preface this with noting that I rarely write elisp. If there are rules or best practices for what follows regarding equality other than the docstrings, I don't know about them.

If a beginner looks at the tests, they might be confused that some use = and others use equal for comparison. They may then decide to discover that there's =/eq/eql/equal/char-equal/... and so on. Aside from that, if I write a function that I know will only ever return integers, I'll use =. If it could also return nil, I'd blanket use equal (or possibly even eql instead.

Are the other exercises in the track consistent with comparisons?

@berquist
Copy link
Contributor Author

berquist commented Sep 3, 2023

Poke. Can I get some feedback on this?

@BNAndras
Copy link
Member

= is specifically recommended for comparing numerical equality per the Emacs Lisp Reference Manual. equal could work here, but it doesn't indicate our intent clearly since it can compare any Lisp objects. = only works with numbers. In an untyped language, that can be useful, and students will likely see = in other Elisp code. Therefore, I'm not sure if I want to switch out the forms.

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