emacs-lisp icon indicating copy to clipboard operation
emacs-lisp copied to clipboard

binary-search: use equal for all numeric test comparisons

Open berquist opened this issue 1 year ago • 2 comments

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 avatar Jun 24 '23 03:06 berquist

Poke. Can I get some feedback on this?

berquist avatar Sep 03 '23 03:09 berquist

= 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.

BNAndras avatar Apr 23 '24 13:04 BNAndras