-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Han-Wen and all,
I can't upload the patch-set to Rietveld, and I seem to have lost
ownership of the issue on Reitveld, so I can't close it and open a new
issue either.

On 30/08/10 03:31, Han-Wen Nienhuys wrote:
> On Sat, Aug 28, 2010 at 4:16 PM, Ian Hulin <i...@hulin.org.uk> wrote:
>> (define (make-music-type-predicate . music-types)
>>  (define ((make-music-type-predicate-aux mtypes) expr)
>>    (if (null? mtypes)
>>        #f
>>        (or (eqv? (car mtypes) (ly:music-property expr 'name))
>>            ((make-music-type-predicate-aux (cdr mtypes)) expr))))
>>  (make-music-type-predicate-aux music-types))
>>
>> I'm a bit puzzled by this code.  Even if we move the nested definition
>> out from within make-music-predicate, how does it work?  Variable
>> make-music-type-predicate is not declared anywhere else, and yet here we
>> appear to ask guile to resolve and call it before it is declared and
>> bound to anything?
> 
> are you sure? I only see calls to the -aux helper.
> 
I'd forgotten about currying functions. Neil picked up about the need to
use a new module in 1.9.  I've found a way of conditionally using it if
we're running with guile V1.9+.

>> Trying this in guile V1.8.7 repl with a dummy for ly:music-property and
>> it will work as written, but in V1.9.11 it always fails with
>> ERROR: in procedure macro-expand:
>> ERROR: source expression failed to match any pattern in (define
>> ((make-music-type-predicate-aux mtypes) expr)  (if (null? mtypes) #f (or
>> (eqv? (car mtypes) (ly:music-property expr 'name))
>> ((make-music-type-predicate-aux (cdr mtypes)) expr))))
>>
>> V1.9.11 throws the error whether or not the repl is called with
>> - --no-auto-compile.  It also doesn't help to try and un-nest the inner
>> (define and declare it at top-level.
> 
> Where is the latest version of this patch?  I downloaded a version
> from rietveld which required the following patch to get to
> display-lily.scm
> 
Stray dots removed in attached path - along with handler in
ergonomic-simple-format.
> commit 57992da984aaf16d6161dc44e5d9f7cb290ac813
> Author: Han-Wen Nienhuys <han...@lilypond.org>
> Date:   Sun Aug 29 23:30:55 2010 -0300
> 
>     Remove stray dots.
> 
> diff --git a/scm/lily.scm b/scm/lily.scm
> index 0aa2ad4..f898962 100644
> --- a/scm/lily.scm
> +++ b/scm/lily.scm
> @@ -213,9 +213,9 @@ messages into errors.")
>    format)
> 
>  (define (simple-format-handler dest . rest)
> -    (if (string? dest)
> -        (apply fancy-format (cons #f (cons dest . rest)))
> -        (apply fancy-format (cons dest . rest))))
> +  (if (string? dest)
> +      (apply fancy-format (cons #f (cons dest rest)))
> +      (apply fancy-format (cons dest rest))))
> 

>> Patrick and Neil, do I have to fix all the compatibility problems in all
>> the scm files loaded by lily.scm in order to push what we have so far?
> 
> As long as the compile for 1.8 keeps working, I don't think it's a
> problem incrementally tackling 1.9  compatibility problems.
> 
Cheers,
Ian



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMfUHYAAoJEBqidDirZqASIM8IAIgvhpveVxuj4OpHEom4xSpX
xDe2zhrn575cC8dfg876RMET9Swa54q/6EAG2AxH9nSEynJOS5VEFMCzRrwkisfS
fFrpmguluydqZ6FDjc4q/Ia1h0GGiH0CHWSMRow2WhVILMQtBKBnQBhRkYfU265X
ZwTNINt4/alFnjhnO9oJv9qnbQbLWL15g6hwzRvOLBbrOVONeVMl3TQF/tbt00Po
DPngHhizsqguA7YkG8fgNaylo/5MbHphG+yLzkkkzm97I8DSlpvKhkfuGbSZU7p3
ILzp/yQjEZ7gqyuZY6uSyc8sbwSQN0HHq7zrBEchUI3fa8y51MvTvudKWy27c3U=
=cnFp
-----END PGP SIGNATURE-----
>From 07249825a5f9485c554b2df10d9b443b770eec3d Mon Sep 17 00:00:00 2001
From: Ian Hulin <i...@hulin.org.uk>
Date: Tue, 31 Aug 2010 18:42:42 +0100
Subject: [PATCH] T1224: Avoid using deprecated %module-public-interface in guile	initialisation.

1. ly-module.cc:ly_make_module
 Replace call using %module-public-interface
 with shim supplied by guile developers.  Also replace reference to
 "the-scm-module" with "the-root-module" to ensure compatibility
 with Guile V2.0.
2. ly_module.cc:ly_use_module
 Reorganise and comment routine to aid maintenance.
3. lily.scm
 Add in module-export-all! shim for Guile V1.8.7 and test for Guile version.
 Add in shim to use (ice-9 curried-definitions) if running Guile V2.0
4. Remove stray dots in ergonomic-simple-format etc.
5. Make success and warning messages in ly:exit translatable.
6. Move public definitions of make-rhythmic-location etc. from
 clip-region.scm to output-lib.scm.
---
 lily/ly-module.cc   |   46 +++++++++++++++++++++++++----------
 scm/clip-region.scm |   66 ++++++++++++++-------------------------------------
 scm/lily.scm        |   45 +++++++++++++++++++++++++++++++----
 scm/output-lib.scm  |   50 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+), 66 deletions(-)

diff --git a/lily/ly-module.cc b/lily/ly-module.cc
index 42ff2f8..ff365b8 100644
--- a/lily/ly-module.cc
+++ b/lily/ly-module.cc
@@ -24,25 +24,34 @@
 #include "protected-scm.hh"
 
 
+
 SCM
 ly_make_module (bool safe)
 {
   SCM mod = SCM_EOL;
   if (!safe)
     {
-      SCM maker = ly_lily_module_constant ("make-module");
-
-      SCM scm_module = ly_lily_module_constant ("the-scm-module");
+      /* Look up (evaluate) Scheme make-module function and call it */
 
+      SCM maker = ly_lily_module_constant("make-module");
       mod = scm_call_0 (maker);
-      scm_module_define (mod, ly_symbol2scm ("%module-public-interface"),
-			 mod);
-
+      /* Look up and call Guile module-export-all! or Lilypond-defined
+         compatible version when using Guile V1.8 */
+      SCM module_export_all_x = ly_lily_module_constant ("module-export-all!");
+      scm_call_1 (module_export_all_x, mod);
+
+      /* Evaluate Guile module "the-root-module",
+         and ensure we inherit definitions from it and the "lily" module
+         N.B. this used to be "the-scm-module" and is deprecated in
+         Guile V1.9/2.0
+         */
+      SCM scm_module = ly_lily_module_constant ("the-root-module"); 
       ly_use_module (mod, scm_module);
       ly_use_module (mod, global_lily_module);
     }
   else
     {
+      /* Evaluate and call make-safe-lilypond-module */
       SCM proc = ly_lily_module_constant ("make-safe-lilypond-module");
       mod = scm_call_0 (proc);
     }
@@ -54,19 +63,30 @@ ly_make_module (bool safe)
 SCM
 ly_use_module (SCM mod, SCM used)
 {
-  SCM expr
-    = scm_list_3 (ly_symbol2scm ("module-use!"),
-		  mod,
-		  scm_list_2 (ly_symbol2scm ("module-public-interface"),
-			      used));
-
+  SCM expr = SCM_EOL;
+  /*
+    Pick up the module's interface definition.
+    TODO - Replace inline evaluations (interpreted)
+    with guile API calls if these become available.
+  */
+  SCM scm_module_use = ly_symbol2scm ("module-use!");
+  SCM scm_module_public_interface = ly_symbol2scm ("module-public-interface");
+  SCM iface = scm_list_2 (scm_module_public_interface, used);
+  /*
+    Set up to interpret
+    '(module_use! <mod> (module-public-interface <used>) )'
+  */
+  expr = scm_list_3 (scm_module_use, mod, iface);
+  /*
+    Now return SCM value, this is the result of interpreting
+    '(eval (module_use! <mod> (module-public-interface <used>)) "lily")'
+  */
   return scm_eval (expr, global_lily_module);
 }
 
 #define FUNC_NAME __FUNCTION__
 
 
-
 SCM
 ly_module_symbols (SCM mod)
 {
diff --git a/scm/clip-region.scm b/scm/clip-region.scm
index 14f593a..1c0a640 100644
--- a/scm/clip-region.scm
+++ b/scm/clip-region.scm
@@ -19,55 +19,25 @@
 
 (use-modules (lily))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; The procedures shown in this list have been moved to
+;; scm/output-lib.scm
+;;
+;;
+;; 	(define-public (make-rhythmic-location bar-num num den)
+;: 	(define-public (rhythmic-location? a)
+;; 	(define-public (make-graceless-rhythmic-location loc)
+;; 	(define-public rhythmic-location-measure-position cdr)
+;; 	(define-public rhythmic-location-bar-number car)
+;; 	(define-public (rhythmic-location<? a b)
+;:	(define-public (rhythmic-location<=? a b)
+;:	(define-public (rhythmic-location>=? a b)
+;;	(define-public (rhythmic-location>? a b)
+;:	(define-public (rhythmic-location=? a b)
+;;	(define-public (rhythmic-location->file-string a)
+;;	(define-public (rhythmic-location->string a)
 
-(define-public (make-rhythmic-location bar-num num den)
-  (cons
-   bar-num (ly:make-moment num den)))
-
-(define-public (rhythmic-location? a)
-  (and (pair? a)
-       (integer? (car a))
-       (ly:moment? (cdr a))))
-
-(define-public (make-graceless-rhythmic-location loc)
-  (make-rhythmic-location
-   (car loc)
-   (ly:moment-main-numerator (rhythmic-location-measure-position loc))
-   (ly:moment-main-denominator (rhythmic-location-measure-position loc))))
-		   
-					     
-(define-public rhythmic-location-measure-position cdr)
-(define-public rhythmic-location-bar-number car)
-
-(define-public (rhythmic-location<? a b)
-  (cond
-   ((< (car a) (car b)) #t)
-   ((> (car a) (car b)) #f)
-   (else
-    (ly:moment<? (cdr a) (cdr b)))))
-
-(define-public (rhythmic-location<=? a b)
-  (not (rhythmic-location<? b a)))
-(define-public (rhythmic-location>=? a b)
-  (rhythmic-location<? a b))
-(define-public (rhythmic-location>? a b)
-  (rhythmic-location<? b a))
-
-(define-public (rhythmic-location=? a b)
-  (and (rhythmic-location<=? a b)
-       (rhythmic-location<=? b a)))
-
-
-(define-public (rhythmic-location->file-string a)
-  (ly:format "~a.~a.~a"
-	  (car a)
-	  (ly:moment-main-numerator (cdr a))
-	  (ly:moment-main-denominator (cdr a))))
-
-(define-public (rhythmic-location->string a)
-  (ly:format "bar ~a ~a"
-	  (car a)
-	  (ly:moment->string  (cdr a))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  Actual clipping logic.
diff --git a/scm/lily.scm b/scm/lily.scm
index 4a00ab6..e049aa3 100644
--- a/scm/lily.scm
+++ b/scm/lily.scm
@@ -196,6 +196,10 @@ messages into errors.")
 
 					;(set-debug-cell-accesses! 1000)
 
+;;; Boolean thunk - are we integrating Guile V2.0 or higher with Lilypond?
+(define-public (guile-v2 )
+  (string>? (version) "1.9.10"))
+
 (use-modules (ice-9 regex)
               (ice-9 safe)
               (ice-9 format)
@@ -209,6 +213,22 @@ messages into errors.")
               (scm memory-trace)
               (scm coverage))
 
+(define-public _ gettext)
+;;; Modules and scheme files loaded by lily.scm use currying
+;;  in Guile V2 this needs a module which is not present in Guile V1.8
+;;
+;; TODO add in modules for V1.8,7 deprecated in V2.0 and integrated
+;; into Guile base code, like (ice-9 syncase).
+;;
+(cond-expand
+  ((or guile-v2)
+   (if (ly:get-option 'verbose)
+       (ly:progress  (_ "Using (ice-9 curried-definitions) module\n"))
+   (use-modules (ice-9 curried-definitions))))
+  (else
+    (if (ly:get-option 'verbose)
+        (ly:progress  (_ "module (ice-9 curried-definitions) not in Guile 1.8\n")))))
+  
 (define-public fancy-format
   format)
 
@@ -250,6 +270,7 @@ messages into errors.")
 (if (ly:get-option 'trace-scheme-coverage)
     (coverage:enable))
 
+
 (define-public parser #f)
 
 (define music-string-to-path-backends
@@ -258,14 +279,13 @@ messages into errors.")
 (if (memq (ly:get-option 'backend) music-string-to-path-backends)
     (ly:set-option 'music-strings-to-paths #t))
 
-(define-public _ gettext)
 
 (define-public (ly:load x)
   (let* ((file-name (%search-load-path x)))
     (if (ly:get-option 'verbose)
 	(ly:progress "[~A" file-name))
     (if (not file-name)
-	(ly:error (_ "cannot find: ~A") x))
+        (ly:error(_"cannot find: ~A") x))
     (primitive-load file-name)
     (if (ly:get-option 'verbose)
 	(ly:progress "]\n"))))
@@ -299,7 +319,22 @@ messages into errors.")
 		 (eq? (string-ref file-name 2) #\/))))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; If necessary, emulate Guile V2 module_export_all! for Guile V1.8.n
+(cond-expand
+  ((not guile-v2)
+   (define (module-export-all! mod)
+     (define (fresh-interface!)
+       (let ((iface (make-module)))
+         (set-module-name! iface (module-name mod))
+         ;; for guile 2: (set-module-version! iface (module-version mod))
+         (set-module-kind! iface 'interface)
+         (set-module-public-interface! mod iface)
+         iface))
+     (let ((iface (or (module-public-interface mod)
+                      (fresh-interface!))))
+       (set-module-obarray! iface (module-obarray mod))))))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (define (type-check-list location signature arguments)
   "Typecheck a list of arguments against a list of type predicates.
 Print a message at LOCATION if any predicate failed."
@@ -671,8 +706,8 @@ PIDs or the number of the process."
     "Exit function for lilypond"
     (if (not silently)
 	(case status
-	    ((0) (ly:success "Compilation successfully completed"))
-	    ((1) (ly:warning "Compilation completed with warnings or errors"))
+	    ((0) (ly:success (_ "Compilation successfully completed")))
+	    ((1) (ly:warning (_ "Compilation completed with warnings or errors")))
 	    (else (ly:message "")))
 	)
     (exit status)
@@ -808,7 +843,7 @@ PIDs or the number of the process."
              (ly:reset-all-fonts))))
      files)
 
-    ;; we want the failed-files notice in the aggregrate logfile.
+    ;; we want the failed-files noticed in the aggregrate logfile.
     (if ping-log
 	(format ping-log "Failed files: ~a\n" failed))
     (if (ly:get-option 'dump-profile)
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 409e8c1..f9dbbf4 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -173,6 +173,56 @@ and duration-log @var{log}."
 	   letter)))
      radius X)))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; clipping 
+(define-public (make-rhythmic-location bar-num num den)
+  (cons
+   bar-num (ly:make-moment num den)))
+
+(define-public (rhythmic-location? a)
+  (and (pair? a)
+       (integer? (car a))
+       (ly:moment? (cdr a))))
+
+(define-public (make-graceless-rhythmic-location loc)
+  (make-rhythmic-location
+   (car loc)
+   (ly:moment-main-numerator (rhythmic-location-measure-position loc))
+   (ly:moment-main-denominator (rhythmic-location-measure-position loc))))
+
+
+(define-public rhythmic-location-measure-position cdr)
+(define-public rhythmic-location-bar-number car)
+
+(define-public (rhythmic-location<? a b)
+  (cond
+   ((< (car a) (car b)) #t)
+   ((> (car a) (car b)) #f)
+   (else
+    (ly:moment<? (cdr a) (cdr b)))))
+
+(define-public (rhythmic-location<=? a b)
+  (not (rhythmic-location<? b a)))
+(define-public (rhythmic-location>=? a b)
+  (rhythmic-location<? a b))
+(define-public (rhythmic-location>? a b)
+  (rhythmic-location<? b a))
+
+(define-public (rhythmic-location=? a b)
+  (and (rhythmic-location<=? a b)
+       (rhythmic-location<=? b a)))
+
+
+(define-public (rhythmic-location->file-string a)
+  (ly:format "~a.~a.~a"
+	  (car a)
+	  (ly:moment-main-numerator (cdr a))
+	  (ly:moment-main-denominator (cdr a))))
+
+(define-public (rhythmic-location->string a)
+  (ly:format "bar ~a ~a"
+	  (car a)
+	  (ly:moment->string  (cdr a))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; break visibility
-- 
1.7.0.4

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to