Re: [frogs] Re: Named book file suffixes -- regtest?

2009-03-02 Thread Marek Klein
2009/3/2 Carl D. Sorensen c_soren...@byu.edu




 On 3/1/09 2:44 PM, Marek Klein ma...@gregoriana.sk wrote:

 
 
  With your suggestion and one more line of code it works now with
  ly:parser-define!
 
  (define counter-alist '())


 Will it work with the above line missing?  The whole point of using
 ly:parser-define! is to avoid having a global variable.

 When you use

 (define counter-alist '())

 you are defining counter-alist as a global variable.   I think you should
 be
 able to just remove that line.

 Yes, it works. Thanks for explanation. Do you have some list of recomended
studying materials?

-- 
Marek Klein
http://gregoriana.sk
___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: [frogs] Re: Named book file suffixes -- regtest?

2009-03-01 Thread Carl D. Sorensen



On 3/1/09 2:44 PM, Marek Klein ma...@gregoriana.sk wrote:

 
 
 With your suggestion and one more line of code it works now with
 ly:parser-define!
 
 (define counter-alist '())


Will it work with the above line missing?  The whole point of using
ly:parser-define! is to avoid having a global variable.

When you use

(define counter-alist '())

you are defining counter-alist as a global variable.   I think you should be
able to just remove that line.


 
 (define (print-book-with parser book process-procedure)
   (let*
   ((paper (ly:parser-lookup parser '$defaultpaper))
    (layout (ly:parser-lookup parser '$defaultlayout))
    (output-suffix (ly:parser-lookup parser 'output-suffix))
    (counter-alist (ly:parser-lookup parser 'counter-alist))
^^^ Here you're making a local variable counter-alist by getting the
parser value of counter-alist;  I don't like to use the same name for both,
although Scheme allows it.  I would use a variable name like local-counter,
so that there would be no confusion between the two.
    (output-count (assoc-ref counter-alist output-suffix))
    (base (ly:parser-output-name parser)) )
   
   (if (string? output-suffix)
     (set! base (format ~a-~a base (string-regexp-substitute
                        [^a-zA-Z0-9-] _ output-suffix
 
     ;; must be careful: output-count is under user control.
     (if (not (integer? output-count))
     (set! output-count 0))
 
     (if ( output-count 0)
     (set! base (format #f ~a-~a base output-count)))
     (ly:parser-define! parser 'counter-alist (assoc-set! counter-alist
 output-suffix (1+ output-count)))
^^^Here you do an assoc-set! on the local counter-alist and define the
parser value of counter-alist to be the assoc-set! on the local value.  So I
don't think you ever use the global value of counter-alist.

     (process-procedure book paper layout base)
     ))
 
 

HTH,

Carl



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