You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Daniel Rall <dl...@finemaltcoding.com> on 2003/12/19 21:59:01 UTC
Scoping of inline Velocimacros
I'm tracking a possible bug with scoping of inline Velocimacros in Velocity core
with 1.4 RC1. I'm seeing inline macros clobbering macros defined at the global
scope in a Velocimacro library file.
Observed behavior:
1. #foo(arg1) is defined in the global macros file, and parsed at startup. The
configuration allows for inline macros.
2. template1.vm is run and uses #foo(arg1) fine.
3. template2.vm inlines a #foo(arg1 arg2) macro definition, which it in turn
uses (overriding the globally-scoped definition which has only a single
argument). This also works fine.
4. template1.vm is run again, and again trying to use #foo(arg1).
Unfortunately, that macro definition has been clobbered by #foo(arg1 arg2), and
the error message "VM error : foo. Null AST" is logged.
Expected behavior:
The inline macro definition should be scoped to the template in which it was
defined, and overriding any globally defined macro of the same name _for that
template only_. Velocimacro overloading need not be handled (yet).
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
Re: Scoping of inline Velocimacros
Posted by Geir Magnusson Jr <ge...@4quarters.com>.
On Dec 19, 2003, at 3:59 PM, Daniel Rall wrote:
> I'm tracking a possible bug with scoping of inline Velocimacros in
> Velocity core with 1.4 RC1. I'm seeing inline macros clobbering
> macros defined at the global scope in a Velocimacro library file.
>
>
> Observed behavior:
>
> 1. #foo(arg1) is defined in the global macros file, and parsed at
> startup. The configuration allows for inline macros.
>
> 2. template1.vm is run and uses #foo(arg1) fine.
>
> 3. template2.vm inlines a #foo(arg1 arg2) macro definition, which it
> in turn uses (overriding the globally-scoped definition which has only
> a single argument). This also works fine.
>
> 4. template1.vm is run again, and again trying to use #foo(arg1).
> Unfortunately, that macro definition has been clobbered by #foo(arg1
> arg2), and the error message "VM error : foo. Null AST" is logged.
>
>
> Expected behavior:
>
> The inline macro definition should be scoped to the template in which
> it was defined, and overriding any globally defined macro of the same
> name _for that template only_. Velocimacro overloading need not be
> handled (yet).
The problem is that replacement of global is default, and since we
don't distinguish by sig but by name, it gets nuked. We'll add the
registration by sig so we can do cooler things later.
Until then, you should be able to turn on the VM namespaces :
velocimacro.permissions.allow.inline.local.scope = true
--
Geir Magnusson Jr 203-247-1713(m)
geir@4quarters.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org