emacs-lisp
emacs-lisp copied to clipboard
binary-search: use equal for all numeric test comparisons
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?
Poke. Can I get some feedback on this?
=
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.