* Q about format's behavior with ~R directive @ 2021-02-04 21:34 Sudarshan S Chawathe 2021-02-04 23:41 ` Charles 2021-02-05 0:09 ` Per Bothner 0 siblings, 2 replies; 5+ messages in thread From: Sudarshan S Chawathe @ 2021-02-04 21:34 UTC (permalink / raw) To: Kawa mailing list With the code (format #t "~R~%" 100) I get hundred but with the Common Lisp equivalent (I think) (format t "~R~%" 100) in SBCL I get instead one hundred I am unsure of how tightly specified any of this is, but to me the SBCL output makes more sense. Is this expected, allowed, by design, a bug, or something else? A related question: Is it correct that Kawa uses SLIB's test file for format (formatst.scm in testsuite) but not SLIB's implementation of format? Regards, -chaw ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Q about format's behavior with ~R directive 2021-02-04 21:34 Q about format's behavior with ~R directive Sudarshan S Chawathe @ 2021-02-04 23:41 ` Charles 2021-02-04 23:42 ` Charles 2021-02-05 0:09 ` Per Bothner 1 sibling, 1 reply; 5+ messages in thread From: Charles @ 2021-02-04 23:41 UTC (permalink / raw) To: Sudarshan S Chawathe; +Cc: Kawa mailing list Hi, On Thu, Feb 4, 2021 at 10:33 PM Sudarshan S Chawathe <chaw@eip10.org> wrote: > With the code > > (format #t "~R~%" 100) > > I get > > hundred > > but with the Common Lisp equivalent (I think) > > (format t "~R~%" 100) > > in SBCL I get instead > > one hundred > > I am unsure of how tightly specified any of this is, but to me the SBCL > output makes more sense. Is this expected, allowed, by design, a > bug, or something else? There isn't a specification to my knowledge on the specific language used to count the numbers, although in this case Kawa is an oddity. I attached a patch to fix that. The testsuite errors for me from a fresh git clone and it's been a while since I've contributed, so I don't know if it breaks in other areas aside from the obvious formatting cases. > > > A related question: Is it correct that Kawa uses SLIB's test file for > format (formatst.scm in testsuite) but not SLIB's implementation of > format? > > I don't know, but I would guess it's another under specified area, for the the english number formatting in particular, // Inspired by the Slib version, which is inspired // by Bruno Haible's CLisp function format-small-cardinal. -- Kind regards, Charles. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Q about format's behavior with ~R directive 2021-02-04 23:41 ` Charles @ 2021-02-04 23:42 ` Charles 2021-02-05 1:04 ` Per Bothner 0 siblings, 1 reply; 5+ messages in thread From: Charles @ 2021-02-04 23:42 UTC (permalink / raw) To: Sudarshan S Chawathe; +Cc: Kawa mailing list [-- Attachment #1: Type: text/plain, Size: 488 bytes --] On Thu, Feb 4, 2021 at 11:41 PM Charles <chturne@gmail.com> wrote: > > There isn't a specification to my knowledge on the specific language used > to count the numbers, although in this case Kawa is an oddity. I attached a > patch to fix that. The testsuite errors for me from a fresh git clone and > it's been a while since I've contributed, so I don't know if it breaks in > other areas aside from the obvious formatting cases. > And with that patch I mentioned ... B.R, Charles. [-- Attachment #2: 0001-Make-R-cardinal-counting-more-consistent.patch --] [-- Type: text/x-patch, Size: 1802 bytes --] From 085bc7cb13213a21c5397e49457e16b580123766 Mon Sep 17 00:00:00 2001 From: Charles Turner <chturne@gmail.com> Date: Thu, 4 Feb 2021 23:31:30 +0000 Subject: [PATCH] Make ~R cardinal counting more consistent (format #t "~R" 100) returns "hundred", whereas other Lisps tend to return "one hundred". It's arguable that both are in some sense correct (since this is not an area heavily specified anywhere), but it's not good that we're inconsistent, since we also return (format #t "~R" 1000) as "one thousand". Reported by Sudarshan S Chawathe. --- gnu/kawa/format/EnglishIntegerFormat.java | 2 +- testsuite/formatst.scm | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gnu/kawa/format/EnglishIntegerFormat.java b/gnu/kawa/format/EnglishIntegerFormat.java index 16f72e8c7..16b246199 100644 --- a/gnu/kawa/format/EnglishIntegerFormat.java +++ b/gnu/kawa/format/EnglishIntegerFormat.java @@ -78,7 +78,7 @@ public class EnglishIntegerFormat extends java.text.NumberFormat { int num100s = num / 100; num = num % 100; - if (num100s > 1) + if (num100s >= 1) { sbuf.append(ones[num100s]); sbuf.append(' '); diff --git a/testsuite/formatst.scm b/testsuite/formatst.scm index 055d03767..35a4ad23e 100644 --- a/testsuite/formatst.scm +++ b/testsuite/formatst.scm @@ -28,7 +28,7 @@ ; (newline) ; (format:abort))) -(test-begin "format" 454) +(test-begin "format" 455) (define-syntax test (syntax-rules () ((test format-args out-str) @@ -155,6 +155,7 @@ (test '("~r" 4) "four") (test '("~r" 10) "ten") (test '("~r" 19) "nineteen") +(test '("~r" 101) "one hundred one") (test '("~r" 1984) "one thousand, nine hundred eighty-four") (test '("~:r" -1984) "minus one thousand, nine hundred eighty-fourth") -- 2.27.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Q about format's behavior with ~R directive 2021-02-04 23:42 ` Charles @ 2021-02-05 1:04 ` Per Bothner 0 siblings, 0 replies; 5+ messages in thread From: Per Bothner @ 2021-02-05 1:04 UTC (permalink / raw) To: Charles, Sudarshan S Chawathe; +Cc: Kawa mailing list On 2/4/21 3:42 PM, Charles via Kawa wrote: > And with that patch I mentioned ... Thanks - checked in. -- --Per Bothner per@bothner.com http://per.bothner.com/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Q about format's behavior with ~R directive 2021-02-04 21:34 Q about format's behavior with ~R directive Sudarshan S Chawathe 2021-02-04 23:41 ` Charles @ 2021-02-05 0:09 ` Per Bothner 1 sibling, 0 replies; 5+ messages in thread From: Per Bothner @ 2021-02-05 0:09 UTC (permalink / raw) To: kawa On 2/4/21 1:34 PM, Sudarshan S Chawathe wrote: > A related question: Is it correct that Kawa uses SLIB's test file for > format (formatst.scm in testsuite) but not SLIB's implementation of > format? Of course. If there is a new implementation of an interface, it is even more valuable to test it with the old implementation's tests, to get an understanding of the difference between the implementations, such as what differences are bugs, intentional, or otherwise acceptable. In any case, it is (almost) impossible to have too many tests. The Kawa testsuite includes tests from all kinds of sources. -- --Per Bothner per@bothner.com http://per.bothner.com/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-05 1:05 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-02-04 21:34 Q about format's behavior with ~R directive Sudarshan S Chawathe 2021-02-04 23:41 ` Charles 2021-02-04 23:42 ` Charles 2021-02-05 1:04 ` Per Bothner 2021-02-05 0:09 ` Per Bothner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).