Re: [Boost-docs] [quickbook] Macros and scoping

Subject: Re: [Boost-docs] [quickbook] Macros and scoping
From: Joel de Guzman (joel_at_[hidden])
Date: 2007-07-30 00:53:47


Stjepan Rajko wrote:
> On 7/28/07, Joel de Guzman <joel_at_[hidden]> wrote:
>> Now, I am of the opinion that the proper scope should be the
>> document (global) and section (local), which, unlike include,
>> is properly scoped with nesting.
>>
>> I'd add that the template definition is also a good scope.
>> That is, all macros (and templates!) declared inside a section
>> or template body should be local to that section or template
>> body and all macros and templates before the first section is
>> global to all the sections.
>>
>
> This sounds great to me. One question - are the template/macro
> definitions going to be usable "retroactively" within the appropriate
> scope? What I mean is, if:
>
> [include file_with_some_templates.qbk]
> [include subsection.qbl] [/ uses templates from file_with_some_templates.qbk]
>
> works, would
>
> [include subsection.qbl] [/ uses templates from file_with_some_templates.qbk]
> [include file_with_some_templates.qbk]
>
> also work?

Oh my, sorry, no. That would require a 2-pass parser. Can't you just
include file_with_some_templates.qbk from subsection.qbk to make
sure it's included before use?

> This would be useful if one wanted to define templates that link to
> different section content in the same file as the the section content
> (but outside the [section], of course), and had two sections that
> cross-referenced each other. I imagine this is the behavior you
> envisioned but just making sure.

I'm not sure I get the picture. Could you provide a simple example?

Regards,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

This archive was generated by hypermail 2.1.7 : 2017-11-11 08:50:40 UTC