guile-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 4/4] load: Display modules depth in output when using %loa


From: Maxime Devos
Subject: Re: [PATCH v2 4/4] load: Display modules depth in output when using %load-verbosely.
Date: Mon, 25 Sep 2023 12:40:18 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0



Op 10-09-2023 om 16:46 schreef Maxim Cournoyer:
-          (force-output)))))
+(define (%load-announce file depth)
+  (when %load-verbosely
+    (with-output-to-port (current-warning-port)
+      (lambda ()
+        (let* ((pad-count (- 3 (string-length (number->string depth))))
+               (pad (if (> pad-count 0)
+                        (make-string pad-count #\space)
+                        ""))
+               (visual-depth (if (> pad-count 0)
+                                 (make-string depth #\space)
+                                 "")))
+          (format #t ";;; loading ~a~a ~a~a~%" pad depth visual-depth file)
+          (force-output))))))


I recommend removing that with-output-to-port and instead replace #t in (format #t ...) by (current-warning-port) and adding the relevant argument to force-output.

Sure, it probably usually won't matter much in practice, but who knows, maybe someone will do a system-async-mark (*) that happens to be run inside the with-output-to-port and which uses (current-output-port), in which case (with-output-to-port ...) would interfere.

(Note: if you do a system-async-mark that prints output, when possible I recommend that the interrupt procedure doesn't assume the port isn't temporarily changed.)

(*) Roughly similar to C signal handlers.

(I now see there is a v3, but the v3 does the same thing ...)

Best regards,
Maxime Devos.

Attachment: OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]