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 Fri, 14 Nov 2003 14:35:36 GMT
On Friday 14 November 2003 14:07, Stefan Bodewig wrote:
> On Fri, 14 Nov 2003, peter reilly <peter.reilly@corvil.com> wrote:
> > <presetdef> expands the properties at the point of use, not
> > at the point of definition.

> Better note that somewhere prominently.
Ok.

> > On Friday 14 November 2003 10:53, Stefan Bodewig wrote:
> >> Peter, Jan, now that we've seen Jose Alberto's use case - what can
> >> macrodef do when we use (local) properties that can't be done with
> >> textual substitutions?
> >
> > I do not like using a different notation for attributes.
>
> unless they are a different thing than properties, if I understand you
> correctly.
Not quite, I mean that if they are differnet from properties, a different
notation should be used, but I do not like using a different notation
in principle.

> > Other than that, there is not much differnce.  Retaining the ${}
> > format (implying using local properties) would be a benefit, in that
> > porting of antcall's would be easier.
>
> OK.
>
> > If attributes are local properties, there is an issue with shadowing
> > of user properties.
>
> Actually, shadowing any properties, but that's an issue of <local> in
> general.
>
> >> The only expression evaluation we have in Ant is property expansion
> >> and that would have been performed before the value of the
> >> attribute gets used - and exactly once - no matter how we implement
> >> it, wouldn't it?
> >
> > Not quite, the expansion gets performed just before a task is run,
> > and with macrodef and presetdef, the UE's are stored and (for
> > macrodef's case) copied. If the expansion is done by
> > macrodef/presetdef, it is difficult to stop the expansion being done
> > again later.
>
> At what stage?  I mean, is the a way that
>
> <property name="foo" value="${bar}"/>
> <property name="bar" value="baz"/>
>
> was defined and a text of ${foo} somewhere inside a macro (pr
> presetdefed task) would end up being resolved to baz?  I.e. is it
> possible that the same string undergoes macro expansion more than
> once?

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.

Peter

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


Mime
View raw message