[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Dave.Touretzky@B.GP.CS.CMU.EDU: pluralization: two proposals]



Okay, let me state my proposal a different way:

The current ~P format directive is lame; it should either be fixed or
flushed.  It cannot even handle all the standard plural forms (those
requiring "es" endings), not to mention the non-standard plurals
(mouse/mice, etc.)  And of course, it's only useful for English.

While it's true, as Moon points out, that we can flush the number-dependent
conditional altogether and replace it with Lisp code, I think the resulting
code would be more verbose and cumbersome than what a properly designed
format directive offers.  Generating number-dependent strings (which
includes things like the "is/are" distinction and possessives, as well as
plural suffixes) is a pretty common operation, so it would be of some
benefit to streamline it.

My proposal, which would work for many languages besides English, is to
replace ~P with a new conditional form which would select the singular
case only when the argument was EQL to 1.

   ~:@[singular~;plural~]

 Negative numbers would thus automatically use the plural form, as is
correct in English.  The standard ~[] conditional cannot handle negatives
at all.  Compare the following code fragment using Lisp code (as Moon
suggests) vs. the proposed pluralization operator:

(defun report (n)
  (format t "~&There ~A ~D bad ~A to be fixed."
    (if (eql n 1) "is" "are")
    n
    (if (eql n 1) "mouse" "mice")))

(defun report (n)
  (format t
     "~&There ~:@[is~;are~]~:* ~D~:* bad ~:@[mouse~;mice] to be fixed." n))


Of course, it would be better to use ~P to name this new operator; that way
we could use ~:P to combine it with the ~:* operation.  In fact, it would
be most convenient to make the : modifier back up one arg AFTER the
directive has been performed, and the @ modifier back up one arg BEFORE
performing the directive.  Then the above example would look like this:

(defun report (n)
  (format t
    "~&There ~:P[is~;are~] ~D bad ~@P[mouse~;mice] to be fixed." n))

The only reason not to usurp ~P for this number-dependent conditional would
be for compatibility with existing code.

-- Dave