Re: Solution for including a file only once

2010-02-12 Thread Karl Hammar
Reinhold Kainhofer: ... > In my view there are two different kinds of include uses: > 1) To include package-like .ily files, which define additional functionality. > There many utility functions really might/should be in their own namespace, > but many definitions (and in particular all \header,

Re: Solution for including a file only once

2010-02-11 Thread Carl Sorensen
On 2/11/10 1:54 PM, "Michael J. O'Donnell" wrote: > Carl, > > includeIfAbsent is indeed the sort of void music function that you > mention. I gave myself a \voidMusic utility function to help me remember > it when I need it. Now, I realize that for other purposes I would also > like a \nullMu

Re: Solution for including a file only once

2010-02-11 Thread Michael J. O'Donnell
Thanks, Carl. I was hunting for a music void before, and missed it. I have several uses for it. I'm very fuzzy on using parser vs. (ly:parser-clone parser). I have a pretty good guess what it means technically at the low level (presumably parser is an object with state, and the clone gives a separ

Re: Solution for including a file only once

2010-02-11 Thread Hans Aberg
On 11 Feb 2010, at 18:18, Michael J. O'Donnell wrote: At present, I am seeking an add-on solution, involving a definition that I can put in a utility file to include. I think I am near finding that. I am not ready to hack the lexical analyzer, and I think that should be pondered carefully,

Re: Solution for including a file only once

2010-02-11 Thread Carl Sorensen
On 2/11/10 11:05 AM, "Michael J. O'Donnell" wrote: > Here's what I *now think* is correct code O:-) : > > includeIfAbsent = > > #(define-music-function (parser location fileName) (string?) > > (let ((guardName (string-append "Already Got " fileName))) > > (if (not (defined? (string->symbol

Re: Solution for including a file only once

2010-02-11 Thread Reinhold Kainhofer
Am Donnerstag, 11. Februar 2010 19:05:26 schrieb Michael J. O'Donnell: > Here's what I *now think* is correct code O:-) : > > includeIfAbsent = > > #(define-music-function (parser location fileName) (string?) > > (let ((guardName (string-append "Already Got " fileName))) > (if (not (defined? (st

Re: Solution for including a file only once

2010-02-11 Thread Michael J. O'Donnell
Here's what I *now think* is correct code O:-) : includeIfAbsent = #(define-music-function (parser location fileName) (string?) (let ((guardName (string-append "Already Got " fileName))) (if (not (defined? (string->symbol guardName))) (begin (primitive-eval (list 'define (string->symbol guardN

Re: Solution for including a file only once

2010-02-11 Thread Michael J. O'Donnell
Hans and Carl (and the list, which I neglected first time), At present, I am seeking an add-on solution, involving a definition that I can put in a utility file to include. I think I am near finding that. I am not ready to hack the lexical analyzer, and I think that should be pondered carefully, p

Re: Solution for including a file only once

2010-02-11 Thread Reinhold Kainhofer
Am Donnerstag, 11. Februar 2010 18:18:52 schrieb Michael J. O'Donnell: > For the very short term, I expect that "\includeIfAbsent", or whatever > we call it, will be most useful if it duplicates the current behavior of > "\include" as much as possible, except when it does nothing due to a > previou

Re: Solution for including a file only once

2010-02-11 Thread Michael J. O'Donnell
Hans and Carl, At present, I am seeking an add-on solution, involving a definition that I can put in a utility file to include. I think I am near finding that. I am not ready to hack the lexical analyzer, and I think that should be pondered carefully, particularly when a global reconsideration of

Re: Solution for including a file only once

2010-02-11 Thread Hans Aberg
On 11 Feb 2010, at 05:32, Carl Sorensen wrote: I have been hunting, so far in vain, for the code implementing \include, in the hope that I can tweak that code to get the right behavior. It appears to me that \include is implemented in two places: 1) lily/lexer.ll, lines 304-336 2) lily/lil

Re: Solution for including a file only once

2010-02-11 Thread Hans Aberg
On 7 Feb 2010, at 04:51, Michael J. O'Donnell wrote: I *think* that I have the essential solution to include a file exactly once, no matter how many times it is mentioned. That is, with the following definition, \includeIfAbsent "MyFile.ly" should copy in MyFile.ly, just as though you had w

Re: Solution for including a file only once

2010-02-10 Thread Carl Sorensen
On 2/10/10 9:16 PM, "Michael J. O'Donnell" wrote: > > I have been hunting, so far in vain, for the code implementing \include, > in the hope that I can tweak that code to get the right behavior. It appears to me that \include is implemented in two places: 1) lily/lexer.ll, lines 304-336 2)

Re: Solution for including a file only once

2010-02-10 Thread Michael J. O'Donnell
My proposed solution behaves as though you had written { \include "MyFile.ly" } rather than the desired \include "MyFile.ly" Lots of simple debugging code works fine, but in the usual case where MyFile.ly is full of variable definitions, those definitions are not parsed in the outermo