Re: Some :include {once} weirdness
Bram Moolenaar <[email protected]>
| Newsgroups | gmane.comp.tools.aap.user |
|---|---|
| Message-ID | <[email protected]> |
Adriaan de Groot wrote:
> :include {once} is really very strict. It applies the onceness even in
> scopes where the included file has never been seen. For example:
>
> ==main.aap
> :child a/main.aap
> :child b/main.aap
> ==
>
> ==local.aap
> :print Local uses $TOPDIR
> ONCET=$TOPDIR
> ==
>
> ==a/main.aap, b/main.aap
> :include {once} ../local.aap
> :print Recipe uses $?ONCET
> ==
>
> After a/main.aap has included local.aap, b/main.aap doesn't, because
> a/main.aap already has. However, in the scope of b/main.aap, local.aap
> has never been seen. So if I were to use local.aap for setting
> variables, in the scope of b/main.aap those variables will be unset.
> In particular, ONCET is unset in b/main.aap.
>
> This makes {once} even less useful than it might be, since it makes it
> hard to amalgamate recipes under a parent. I need to check which files
> are included {once} from the child recipes, and include them in the
> parent as well, just to be sure that the one child recipe's {once}
> doesn't interfere with the others'.
>
> I think adding a note to the documentation about {once} is in order -
> it makes sense for files defining :routes but for precious little
> else.
The main reason for using {once} is when you have a project that is
split up in sub-projects. You would then include your project-global
settings in the top project recipe and in each sub-project recipe. When
building the whole thing and when building a sub-project the same
settings are used. The {once} then avoids that the settings are loaded
twice when building the whole project, once in the top recipe and again
in the children.
When you want to declare variables locally to the scope of a recipe you
can't use {once}, obviously.
Perhaps adding something to the documentation may indeed avoid that
people try to use {once} for the wrong purpose.
--
hundred-and-one symptoms of being an internet addict:
152. You find yourself falling for someone you've never seen or hardly
know, but, boy can he/she TYPE!!!!!!
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
\\\ Project leader for A-A-P -- http://www.A-A-P.org ///
\\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01