Hi Carl,
(was it your intention to discuss this off-list? I ask because you
didn't cc the list for the last two times.)
Hmmm -- I see your point.
Without looking into the code for each of those grep results, I couldn't
answer. But assoc-get is defined in LilyPond, and was certainly recommended
by Han-Wen when I first started programming Scheme in LilyPOnd.
I wonder if I'm being overly sensitive, or if many of these assoc calls are
left over from before assoc-get was defined.
I would propose to modify assoc-get the way it is indicated in the
attached patch and then migrate all assoc calls to assoc-get calls.
This assoc-get calls would be divided into two classes.
1. Silently set a default value, since there is nothing erroneous happening.
2. Set a default value and output a programming_error, showing the key
which failed.
Of course that would also happen with chain-assoc-get.
I also recognized that some assoc-get or chain-assoc-get calls occur
with #f set as default value, which I think is unnecessary since #f is
the hardcoded default already.
Regards,
Michael
>From 5fb65494ecb7e25d87fdfea6ce2133a818631df8 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Michael=20K=C3=A4ppler?= <xmichae...@web.de>
Date: Fri, 11 Sep 2009 11:44:32 +0200
Subject: [PATCH] Proposal to change ly:assoc-get method.
---
lily/general-scheme.cc | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc
index 43ff745..d6dffb9 100644
--- a/lily/general-scheme.cc
+++ b/lily/general-scheme.cc
@@ -155,7 +155,7 @@ LY_DEFINE (ly_dir_p, "ly:dir?",
LY_DEFINE (ly_assoc_get, "ly:assoc-get",
2, 1, 0,
- (SCM key, SCM alist, SCM default_value),
+ (SCM key, SCM alist, SCM default_value, SCM strict_checking),
"Return value if @var{key} in @var{alist}, else @code{default-value}"
" (or @code{#f} if not specified).")
{
@@ -168,6 +168,9 @@ LY_DEFINE (ly_assoc_get, "ly:assoc-get",
if (default_value == SCM_UNDEFINED)
default_value = SCM_BOOL_F;
+ if (strict_checking == SCM_BOOL_T)
+ programming_error ("Cannot find key ~S in alist, setting to ~S.", ly_scm2string (key), ly_scm2string (default_value));
+
return default_value;
}
--
1.6.0.2
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel