Re: Possible bug

Bram Moolenaar <[email protected]> Sun, 14 Dec 2003 18:53:55 +0100
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
Wytze van der Raay wrote:

> Tim Hemel wrote:
> 
> > ...
> > install:
> >         :print $Subdirs
> >         @for d in expand2list(Subdirs):
> >                 :print $d
> >                 :execute $d/main.aap install
> > ...
> > $ aap install
> > ...
> > Aap: Error in recipe "/usr/home/tim/soekris/main.aap" line 20: NameError: name 'Subdirs' is not defined
> > 
> > Why is this variable not defined in that particular place, but is defined in
> > all the others?
> 
> See http://www.a-a-p.org/exec/ref-varscope.html#id3020160
> Your example will work as expected when you write:
> 
> 	@for d in expand2list(_no.Subdirs):
> 
> for reasons better explained by Bram ...

The "Subdirs" variable apparently exists in another scope, not the
current scope.  Using $Subdirs in an Aap command will automatically
search other scopes, but in Python this doesn't happen, "_no" must be
prepended.

We could not make Python search other scopes when a variable isn't found
in the current scope.  This is because the Python "exec" statement only
accepts a real dictionary, not a user dictionary.

-- 
`The Guide says there is an art to flying,' said Ford, `or at least a
knack. The knack lies in learning how to throw yourself at the ground
and miss.' He smiled weakly.
		-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// 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 is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/