/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ly-module.hh"
-
+#include "ly-module.hh" // pulls in lily-guile.hh and guile-compatibility.hh
#include "warn.hh"
#include "main.hh"
#include "std-string.hh"
return SCM_UNSPECIFIED;
}
-/* Lookup SYM, but don't give error when it is not defined. */
+
+
+/* Lookup SYM, but don't give error when it is not defined.
+ N.B. this is only needed when running with Guile versions
+ prior to V2.0.3, when calls to ly_module_lookup can be replaced
+ with direct calls to the Guile API scm_module_variable in the
+ LilyPond codebase.
+*/
SCM
ly_module_lookup (SCM module, SCM sym)
{
#define FUNC_NAME __FUNCTION__
SCM_VALIDATE_MODULE (1, module);
-
+/*
+ Issue 2758:
+ Guile V2 onward has a scm_module_variable API module.
+ Guile V1.8.7 only has a (module-variable) REPL function, however
+ using ly_lily_module_constant ("module-variable") and calling
+ the memoized result is slow.
+ */
+#if GUILEV1
return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
+#else
+ return scm_module_variable (module, sym);
+#endif
#undef FUNC_NAME
}