I am using the cl-format function from the clojure.pprint library. I am using the ~:[ directive as follows:
(cl-format nil "~:[~;~a~]" arg)
When arg is nil, I get the expected empty string as a return value. However, when arg is non-nil, liike 1, I get an error: "Not enough arguments for format definition." When I pass a second arg to the cl-format function:
(cl-format nil "~:[~;~a~]" 1 2)
it prints 2, so it's acting as if it is absorbing the first argument to check for its non-nil character and then passing the second to the internal format directive.
From my reading of both the CL Hyperspec, and the gigamonkies format reference, the ~:[ should not absorb the argument but pass it on to the internal spec for printing. Is this an error in the implementation of cl-format or am I misinterpreting the spec?
I've looked at the source and it sure looks like the navigator argument to execute-sub-format on line 862 of https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/cl_format.clj should be arg-navigator instead.