Welcome! Please see the About page for a little more info on how this works.

0 votes
in Docs by

The docstring for (bit-shift-left x n) says only "Bitwise shift left". It does not define either x or n.

Below the docstring is a link to the source code, but it does not immediately clear up the question, as it delegates to a method of clojure.lang.Number.

Suggestion: enhance the docstring along the lines of "Bitwise shift x left by n bits".

P.S. Does left mean more-significant everywhere nowadays? As Clojure gets implemented in JS and even stranger environments, could the docstring clarify whether Clojure's left and right have a specified mathematical significance (as the Java Language Specification does) or have host-dependent significance?

P.P.S. Likewise, bit-shift-right.

P.P.P.S. Likewise in the ClojureScript docstrings.

2 Answers

0 votes
selected by
–1 vote

You can easily get answers in your REPL

clj Clojure 1.10.1 (bit-shift-left 1 1) 2 (bit-shift-left 1 2) 4 (bit-shift-left 1 3) 8 (bit-shift-left 1 4) 16 (bit-shift-left 2 1) 4 (bit-shift-left 2 3) 16

these answers will be true. Even if you are running a custom 16-bit JVM on a SNES or if you are running on a odd javascript engine ;)

The question was about improving docstrings.