Subject: Re: bug#73605: [PATCH] Replace SRFI-64 with a new implementation.

From: Tomas Volf <[email-masked]>
Date: Sat, 26 Oct 2024 16:09:48 +0200

Hello,

I was thinking about this and then forgot to reply.  Sorry about that.

Ludovic Courtès <[email-masked]> writes:

> Hi,
>
> lloda <[email-masked]> skribis:
>
>> I'm pleased to see all these fixes. However, I noticed a few breakages. They
>> come from relying on undocumented behavior, but only using the public
>> interface, so others might be affected. I don't propose to patch them, but
>> perhaps to make a note in NEWS or (for the last two) to add a paragraph in the
>> manual explaining how to achieve the same goal – the reference documentation
>> doesn't have enough examples.
>>
>> * test-begin and test-end now require strings. The old version accepted symbols.

No problem with this one.  Even the specification for test-begin does
note:

> Rationale: In some ways using symbols would be preferable. However, we
> want human-readable names, and standard Scheme does not provide a way
> to include spaces or mixed-case text in literal symbols.

I am just thinking how to express it neatly, maybe something like the
following would work well enough?

--8<---------------cut here---------------start------------->8---
--- a/wolfsden/srfi/srfi-64.scm
+++ b/wolfsden/srfi/srfi-64.scm
@@ -513,6 +513,14 @@ returning new test runner.  Defaults to @code{test-runner-simple}.")
 
     ((test-runner-on-group-begin r) r suite-name count)))
 
+(define (%cmp-group-name a b)
+  (match (list a b)
+    (((? string?) (? string?))
+     (string=? a b))
+    (((? symbol?) (? symbol?))
+     (eq? a b))
+    (_ #f)))
+
 (define* (test-end #:optional suite-name)
   "Leave the current test group."
   (let* ((r (test-runner-current))
@@ -520,7 +528,7 @@ returning new test runner.  Defaults to @code{test-runner-simple}.")
 
     (let ((begin-name (car (test-runner-group-stack r)))
           (end-name   suite-name))
-      (when (and end-name (not (string=? begin-name end-name)))
+      (when (and end-name (not (%cmp-group-name begin-name end-name)))
         ((test-runner-on-bad-end-name r) r begin-name end-name)
         (raise-exception (make-bad-end-name begin-name end-name))))
--8<---------------cut here---------------end--------------->8---

Is there more elegant way to express this?

>> * test-approximate requires real arguments. The old version accepted complex arguments.

No objections, since it seems that (imag-part 0) works just fine, I can
basically rewrite it to always consider the input complex, and it will
work.

>> * The exported variable test-log-to-file is gone.

I oppose to restoring this one.  When you loaded test file into REPL, it
used to just litter your file system with random test log files created
in whatever the current working directory is.  I do not consider that to
be a good behavior.

>
> As discussed on IRC, I think we should consider restoring support for
> these idioms, whether or not they conform to the reference, in an effort
> to minimize breakage (especially since this is slated for a point
> release).
>
> WDYT, Tomas?

Reacted above, I am fine with the first two, oppose to the third one.

I will send a patch for the first two today.

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.