ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: Vote: <local> for 1.6
Date Thu, 23 Oct 2003 15:15:14 GMT
On Thursday 23 October 2003 15:42, Jose Alberto Fernandez wrote:
> Notice that following this path (not making locals visible) means
> that <macrodef> defined tasks will behave differently than java written
> tasks, more over it means that macrodef is not really the same as having
> the code in place. Ex:

Yes this is true,
which is why I had macrodef make the locals visible to the macro
instance in the first place.

However I have felt uneasy about it, used to as I am pascal
/algol8/c/c++/java's static scopping for local variables and not
lisp's dynamic extent.
The code to do this was in and out a number of times over the weekend.

One could argue that as macrodef is a macro, the dynamic extent should
be the case (the macro expands into the current element).

However, I think that a static scope as seen from an ant xml script
point of view is the way of least suprise.

Peter
>
> <macrodef name="m">
>   <echo>${a}</echo>
> </macrodef>
>
> <property name="a" value="G"/>
>
> <target name="x">
>   <local name="a" value="L"/>
>   <echo>${a}</echo>
> </target>
>
> <target name="y">
>   <local name="a" value="L"/>
>   <m/>
> </target>
>
> Targets x and y are suppose to do the same thing, at least
> that is what a "macro" is supposed to do. But here the behavior
> changes in unexpected ways depending on whether "a" is local or global.
>
> If I had written <m/> in java, I would see the local value, but since
> I wrote it using <macrodef/> that is not the same. So I can forget
> about writing new tasks by just composing existing tasks toguether. :-(
>
> >   <macrodef name="m">
> >     <sequential>
> >       <echo>${p}</echo>
> >       <antcontrib:if>
> >         <equals arg1="${p}" arg2="my local p"/>
> >         <then>
> >           <antcall target="tm"/>
> >         </then>
> >       </antcontrib:if>
> >     </sequential>
> >   </macrodef>
> >
> >   <target name="x">
> >     <local name="p" value="my local p"/>
> >     <m/>
> >   </target>
> >
> >   <target name="tm">
> >    <echo>${p}</echo>
> >   </target>
> >
> >   <property name="p" value="my global p"/>
> >
> > Peter
> >
> > > Stefan
> >
> > ---------------------------------------------------------------------
> >
> > > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: dev-help@ant.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> > For additional commands, e-mail: dev-help@ant.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message