[pro] Final empty parameters to format directives
Didier Verna
didier at lrde.epita.fr
Thu Jan 27 14:19:47 UTC 2011
Hello,
I just fell upon a case where implementations seem to differ on what to
do. The question is how to interpret a format directive in which the
last parameter is followed by a comma. Consider this test case:
(defun fmt (stream argument colonp atsignp &rest params)
(declare (ignore stream argument colonp atsignp))
(format t "~S~%" params))
(format t "~1,2/fmt/~%" t)
(format t "~1,2,/fmt/~%" t)
(format t "~1,2:/fmt/~%" t)
(format t "~1,2,:/fmt/~%" t)
Here's what you get from various implementations:
SBCL / ECL / ABCL:
(1 2)
(1 2 NIL)
(1 2)
(1 2)
CMU-CL / CCL / CLISP / Allegro / LispWorks:
(1 2)
(1 2)
(1 2)
(1 2)
Funnily, my instinct tells me that nobody's right, as I would have
expected to get this:
(1 2)
(1 2 NIL)
(1 2)
(1 2 NIL)
Indeed, the parameters list is implicitely terminated by the directive
character OR a colon / at-sign. So using a final comma seems to me like
adding another, empty, parameter at the end.
I'm willing to report those divergences to the respective
implementations, but the problem is that I don't really know what to
report :-) Who's right? No matter how I read the spec, I cannot make a
decision and it seems to me that this is an unspecified corner case.
I reckon it's probably not a big deal, but this could be a problem for
user-defined functions relying on the actual number of parameters that
they get.
Comments?
--
Resistance is futile. You will be jazzimilated.
Scientific site: http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com
More information about the pro
mailing list