On Wed, 12 Nov 2003, Jose Alberto Fernandez
<[EMAIL PROTECTED]> wrote:

[scriptdef and beanshell]

> Line numbers never match with that of the srcfiles.  But back to the
> topic.

Looks as if Peter sees the same - a BSF problem of not passing the
correct line number in?

> I want macrodef for when all I need to do is to put toguether
> a group of calls to other tasks in a sequence, which could be
> quite complex, but it does not require any additional computation
> from my part:

And I don't want to take that away - neither from you nor anybody else
8-)

> From: Stefan Bodewig [mailto:[EMAIL PROTECTED] 
>
>> In which situation would "<atributes> modify properties" have 
>> negative effects on what you are planing to do with 
>> <macrodef>?  Do you have an enlightening example?

[attribute is called debug and would shadow a debug property]

> <presetdef name="my.javac">
>    <javac srcdir="src" destdir="classes"
>            deprecation="${deprecation}" debug="${debug}"/>
> </presetdef>

I'd expect that the properties have been expanded at the point of
<presetdef> already so there shouldn't be any shadow affecting that
definition.

> No here the intention of the code writer was to control javac using
> the debug property. But just because I decided to write myMacro with
> an attribute called debug, I am changing the behavior of
> my.java. (if we use locals)

Only if the expansion of properties in presetdef is performed in the
scope of the macro invocation and not at definition time.  But we
could simple use your example with

   <myMacro debug="true">
     <code>
       <echo>${debug}</echo>
     </code>
   </myMacro>

and ask ourselves what the user wanted to say here.  I agree that we
remove the ambiguity when attributes are not properties.

> But wait, what if I actually wanted to change the property?
> Well, in that case you can introduce the <local> yourself
> as part of the code of the macro:

I knew you'd say that (and I even came to this conclusion all by
myself already ;-).

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 may be willing to swallow <local> in 1.6
even if macrodef attributes don't use it.

The main problems other languages have with macros as textual
replacements (i.e. Lisp's defmacro or C's #define) is that the
expression you pass in may be evaluated more than one.  
I.e. #define square(x) x * x and used as square(i++) may lead to
unexpected results.

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?

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to