From: Sjoerd van Leent <svanleent@gmail.com>
To: guile-devel@gnu.org
Subject: Discussion for %display-auto-compilation-messages (and --no-auto-compilation-messages option)
Date: Sat, 01 Mar 2014 23:08:06 +0100 [thread overview]
Message-ID: <53125A46.3010407@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 938 bytes --]
Hi,
I have been having a bit of a go at understanding boot-9.scm. While
investigating it, i found out an interesting bit where SCM code is
compiled to new .GO code when performing fresh-compilation. I found
similar code in the C sources in load.c.
Now I wanted to add an option to disable the display of the compilation
messages so went ahead with creating such an option. However, before I
continue, I want a discussion about two things:
- Shouldn't it be that either the C code or the SCM is responsible for
displaying the messages? If so, I would assume the C code should be
changed to have formal procedures to handle these things.
- Also, is this option in general wanted? If this is the case, I would
also like to clean up the above mess of having two procedures printing
exactly the same kind of information, leading to maintenance issues.
I attached a simple diff file, so everyone could have their opinions shared.
[-- Attachment #2: discussion.patch --]
[-- Type: text/x-patch, Size: 5535 bytes --]
diff --git a/libguile/load.c b/libguile/load.c
index 5019201..48f7443 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -228,6 +228,9 @@ static SCM *scm_loc_fresh_auto_compile;
/* The fallback path for auto-compilation */
static SCM *scm_loc_compile_fallback_path;
+/* Whether or not to display messages for auto-compilation */
+static SCM *scm_loc_display_auto_compilation_messages;
+
/* Ellipsis: "..." */
static SCM scm_ellipsis;
@@ -763,9 +766,12 @@ do_try_auto_compile (void *data)
SCM source = SCM_PACK_POINTER (data);
SCM comp_mod, compile_file;
- scm_puts_unlocked (";;; compiling ", scm_current_error_port ());
- scm_display (source, scm_current_error_port ());
- scm_newline (scm_current_error_port ());
+ if (scm_is_true (*scm_loc_display_auto_compilation_messages))
+ {
+ scm_puts_unlocked (";;; compiling ", scm_current_error_port ());
+ scm_display (source, scm_current_error_port ());
+ scm_newline (scm_current_error_port ());
+ }
comp_mod = scm_c_resolve_module ("system base compile");
compile_file = scm_module_variable (comp_mod, sym_compile_file);
@@ -792,9 +798,12 @@ do_try_auto_compile (void *data)
/* Assume `*current-warning-prefix*' has an appropriate value. */
res = scm_call_n (scm_variable_ref (compile_file), args, 5);
- scm_puts_unlocked (";;; compiled ", scm_current_error_port ());
- scm_display (res, scm_current_error_port ());
- scm_newline (scm_current_error_port ());
+ if (scm_is_true (*scm_loc_display_auto_compilation_messages))
+ {
+ scm_puts_unlocked (";;; compiled ", scm_current_error_port ());
+ scm_display (res, scm_current_error_port ());
+ scm_newline (scm_current_error_port ());
+ }
return res;
}
else
@@ -840,6 +849,13 @@ SCM_DEFINE (scm_sys_warn_auto_compilation_enabled, "%warn-auto-compilation-enabl
#define FUNC_NAME s_scm_sys_warn_auto_compilation_enabled
{
static int message_shown = 0;
+
+ if (scm_is_false (*scm_loc_display_auto_compilation_messages))
+ {
+ /* If auto-compilation messages are not to be shown, this should be set
+ to disable further display of this message */
+ message_shown = 1;
+ }
if (!message_shown)
{
@@ -1136,6 +1152,8 @@ scm_init_load ()
= SCM_VARIABLE_LOC (scm_c_define ("%load-should-auto-compile", SCM_BOOL_F));
scm_loc_fresh_auto_compile
= SCM_VARIABLE_LOC (scm_c_define ("%fresh-auto-compile", SCM_BOOL_F));
+ scm_loc_display_auto_compilation_messages
+ = SCM_VARIABLE_LOC (scm_c_define ("%display-auto-compilation-messages", SCM_BOOL_T));
scm_ellipsis = scm_from_latin1_string ("...");
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index cac058c..5789db0 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -4091,18 +4091,27 @@ when none is available, reading FILE-NAME with READER."
(if (and gostat (more-recent? gostat scmstat))
go-file-name
(begin
- (if gostat
- (format (current-warning-port)
- ";;; note: source file ~a\n;;; newer than compiled ~a\n"
- name go-file-name))
- (cond
- (%load-should-auto-compile
- (%warn-auto-compilation-enabled)
- (format (current-warning-port) ";;; compiling ~a\n" name)
- (let ((cfn (compile name)))
- (format (current-warning-port) ";;; compiled ~a\n" cfn)
- cfn))
- (else #f)))))
+ (let ((newer-message-note "note: source file")
+ (newer-than-compiled-message "newer than compiled"))
+ (if gostat
+ (if %display-auto-compilation-messages
+ (format (current-warning-port)
+ ";;;~a ~a\n;;; ~a ~a\n"
+ newer-message-note
+ name
+ newer-than-compiled-message
+ go-file-name)))
+ (cond
+ (%load-should-auto-compile
+ (%warn-auto-compilation-enabled)
+ (if %display-auto-compilation-messages
+ (begin
+ (format (current-warning-port) ";;; compiling ~a\n" name)))
+ (let ((cfn (compile name)))
+ (if %display-auto-compilation-messages
+ (format (current-warning-port) ";;; compiled ~a\n" cfn))
+ cfn))
+ (else #f))))))
#:warning "WARNING: compilation of ~a failed:\n" name))
(define (sans-extension file)
diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm
index b387eb3..5171ee5 100644
--- a/module/ice-9/command-line.scm
+++ b/module/ice-9/command-line.scm
@@ -133,6 +133,8 @@ If FILE begins with `-' the -s switch is mandatory.
--no-auto-compile disable automatic source file compilation;
default is to enable auto-compilation of source
files.
+ --no-auto-compilation-messages disable display of auto-compilation
+ messages.
--listen[=P] listen on a local port or a path for REPL clients;
if P is not given, the default is local port 37146
-q inhibit loading of user init file
@@ -343,6 +345,10 @@ If FILE begins with `-' the -s switch is mandatory.
(set! %load-should-auto-compile #t)
(parse args out))
+ ((string=? arg "--no-auto-compilation-messages")
+ (set! %display-auto-compilation-messages #f)
+ (parse args out))
+
((string=? arg "--fresh-auto-compile")
(set! %load-should-auto-compile #t)
(set! %fresh-auto-compile #t)
next reply other threads:[~2014-03-01 22:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-01 22:08 Sjoerd van Leent [this message]
2014-03-02 21:13 ` Discussion for %display-auto-compilation-messages (and --no-auto-compilation-messages option) Ludovic Courtès
2014-03-03 15:17 ` Sjoerd van Leent
2014-03-25 20:58 ` Andy Wingo
2014-03-25 21:20 ` Ludovic Courtès
2014-03-26 2:34 ` Mark H Weaver
2014-03-26 3:19 ` Mark H Weaver
2014-03-26 8:18 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53125A46.3010407@gmail.com \
--to=svanleent@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).