lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Language selection code


From: Simon Albrecht
Subject: Re: Language selection code
Date: Fri, 27 Mar 2015 17:31:12 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

Am 27.03.2015 um 14:38 schrieb David Nalesnik:
Hi Simon,


On Thu, Mar 26, 2015 at 6:43 PM, Simon Albrecht <address@hidden <mailto:address@hidden>> wrote:

[...]

    So the roadmap would include
    – discussing design and coding (?)


I haven't gone through this thoroughly, but I did notice that an invalid statement like this
\language general.deutsch.foo
isn't gracefully dealt with.

I haven't studied this enough to diagnose the problem, but I did notice the following:

% extended from music-functions-init.ly:603 <http://music-functions-init.ly:603>
language =
#(define-void-function
  (parser location arg)
  ;; Usage:
  ;; \language input.LANG or
  ;; \language output.LANG or
  ;; \language LANG—which is equivalent to
  ;; \language general.LANG or to the first two combined
  (symbol-list-or-symbol?)
(_i "Define languages for input (i.e. set note names for @var{language}), output (i.e. display tagline and table of contents in @var{language}), or both.")


  (let* ((correct-input (if (> (length arg) 2) #f #t))
         (channel (if (= 2 (length arg)) ;if a channel is given,
                      (car arg)    ;use it
                      'general))     ;else apply to both
         (language (cond ((= 1 (length arg)) (list-ref arg 0))
                     ((= 2 (length arg)) (list-ref arg 1))))


If correct-input is #f, language will be undefined.  You could add
(else #f)
You’re right, that was an oversight on restructuring the code. A previous version had (else #f) here. I intended to replace the test in the following two if clauses by correct-input.


         (input-lang (if language ;if input isn’t wrong
                         language
 'nederlands)) ;default


The boolean value of #<unspecified> is ... #t, so input-lang will select language if the input is not correct. language will be #<unspecified>.

         (output-lang (if language
                          language
                          'english)))

As above.

Possibly you shouldn't bind the variables after correct-input unless the input is correct.
I see – simply aborting the function (with a warning of course) instead of carefully reinstating the default values… And you’re right, using { b } in the example also tests note name language without giving errors. Attached a version with these changes incorporated, without user syntax changes for now.

Yours, Simon

Attachment: define-languages.ly
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]