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: macrodef - do attributes as properties or substitutions
Date Mon, 17 Nov 2003 17:56:32 GMT
On Monday 17 November 2003 15:57, Stefan Bodewig wrote:
> On Fri, 14 Nov 2003, peter reilly <peter.reilly@corvil.com> wrote:
>
> > An example:
> > <target name="s">
> >   <macrodef name="show">
> >    <element name="x"/>
> >    <sequential>
> >        <property name="inmacro" value="Set in macro"/>
> >        <x/>
> >    </sequential>
> >   </macrodef>
> >
> >   <show>
> >     <x>
> >       <echo>inmacro is '${inmacro}'</echo>
> >     </x>
> >   </show>
> > </target>
> > This shows:
> >
> > s:
> > inmacro is 'Set in macro'
> >
> > It would be very difficult to stop this.
>
> So we must ask outselves whether this is good or bad for us.
>
> If the property inmacro has been defined before the macro invocation,
> the task inside the macro will be a noop - the user gets the expected
> behavior.
>
> If it has not been set, well, this might come unexpected.

I suppose it depends on how one sees macrodef. Treated as
a simple macro substition:
 
 <macrodef name="show">
    <element name="x"/>
    <sequential>
        <property name="inmacro" value="Set in macro"/>
        <x/>
    </sequential>
 </macrodef>

 <target name="s">
   <show>
    <x>
       <echo>inmacro is '${inmacro}'</echo>
     </x>
   </show>
</target>

the target "s" would become:
<target name="s">
  <sequential>
       <property name="inmacro" value="Set in macro"/>
       <echo>inmacro is '${inmacro}'</echo>
   </sequential>
</target>
And the above will behave the same as the macrodef version.


>
> But there will never be any double expansion, right?  I mean,
>
>       <echo>inmacro is '$${inmacro}'</echo>
>
> would always result in
>
> > s:
> > inmacro is '${inmacro}'

Yes with the current implementation (not with some of my intermediate
implementations...)

Peter


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


Mime
View raw message