I've never used macrodef in Ant, but would say that I'd find a
"template" definition easiest to understand with the following
structure:

<define id="t">
    <parameters>
        <parameter id="x">
            ... (gives default value)
        </parameter>
    </parameters>
    <body>
        ...
    </body>
</define>

and usage of the form:

<apply refid="t">
    <binding id="x"> (maps to a parameter)
        ... (gives actual value)
    </binding>
</apply>

or something like that.

You might even want to indicate that a given "parameter" is mandatory by
not specifying a default for the parameter.

How does that relate to macrodef? Can this approach be used? Is it worth
it? Just my tuppence worth. ;n)

Phil

On Fri, 2004-12-10 at 15:58, Dominique Devienne wrote:

> Thanks for the feedback Peter. I'll be off line most of Dec, so for now I'll 
> just attach my modified MacroDef/Instance files in bugzilla until I can 
> properly try to integrate it to Ant (it's not very tested yet, and not unit 
> tested at all either). I worked off the 1.6 branch anyway, and this would 
> need to happen in the HEAD I guess, no?
>  
> About (1), you're right. I used my <bm:sequential> which is more like 
> <xsl:if> than <ac:if>, because it has no <then> or <else> block. 90% of the 
> time, I don't need if/then/else, just if. I find having conditions on 
> <sequential> very natural and the Ant way ;-)
>  
> (2) I initialy thought about putting it in the declaration, but I didn't 
> think I could pull it off. And after using it, I thought it was easier to 
> read the macro code with the defaults inside the macro impl instead of in the 
> element declaration.
>  
> (3) I agree it requires to get used to, but for the client code actually 
> looks more 'normal' and task-like. Like (4), one doesn't have to use it.
>  
> (4) Again, it's a question of reuse. I don't deny using @{attr} in the macro 
> instance looks strange, but I did naturally try to use it with the regular 
> Ant <macrodef> to learn it didn't work. I wanted to avoid duplicate some info 
> I had already entered in a macro attribute. I'd say it's a nice to have 
> thing, and one doesn't have to use it.
>  
> BTW, after droping this code in my Antlib, my checkstyle Javadocs error count 
> jumped from 0 to 35 ;-) I'll try to fix this too. (I have a checkstyle config 
> for Javadocs only). --DD
> 
> ________________________________
> 
> From: Peter Reilly [mailto:[EMAIL PROTECTED]
> Sent: Fri 12/10/2004 9:15 AM
> To: Ant Developers List
> Subject: Re: About <macrodef> in the trenches
> 
> 
> 
> All these features sould great.
> 
> 1) this attribute is good.
>      however,  it is only really usefull in combination with the iftrue
> attribute,
>      or with ant-contrib "if" task
> 
> 2) a default value for the element is good. The default value should
>     be in the declaration, but it is ok to have it the body of the
>     macrodef.
> 
> 3) this sounds good if a little stange initially.
> 
> 4) this is good as well, if one is useing elements with macrodefs a lot.
> It may
>     be a bit confusing.
> 
> I would say go for it!
> 
> Peter
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Phil Weighill-Smith <[EMAIL PROTECTED]>
Volantis Systems

Reply via email to