ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Amerige <Steve.Amer...@sas.com>
Subject runtarget vs. macrodef for Procedural Ant Programming
Date Thu, 28 Jul 2011 19:31:49 GMT
Hi all,

What are the pros/cons of choosing runtarget vs. macrodef as "functions" under these assumptions:

    1. Ant is going to be used as a procedural language for complex coding.  Please just accept
this assumption. :-)
    2. No more than a page or so of coding should be in any one macrodef or runtarget to keep
the business logic understandable.
    3. Ant-Contrib is going to be used within the functions.
    4. The code should be reasonably modular to encourage creating reusable code with style
choices that help to differentiate 
between public APIs, private APIs, volatile variables (any previous value is discarded), and
test APIs.
    5. Ant 1.7 is going to be used.

I tend to prefer runtarget over macrodef for zero-argument functions for these reasons:

1. The syntax of a target name allows for more characters than a macrodef name.
2. Eclipse Outline view allows for me to create the distinction between public and test APIs
vs. private APIs.
3. I'm concerned that some constructs if put in a macrodef will fail that would otherwise
succeed in a target.

TARGET NAME SYNTAX vs. MACRODEF SYNTAX

A macrodef name cannot begin with "." or "-" and cannot have embedded spaces, but a target
can.  With runtarget, I can use naming 
conventions that deal with the problem that Ant 1.7 has very limited scoping capabilities.
 I use these conventions for names:

    * public names       publicAPIName
    * private names      _privateAPIName or -privateAPIName (the latter discourages command-line
use)
    * volatile names     __volatileName
    * test names         _.testAPIName

ECLIPSE OUTLINE VIEW

One advantage of using runtarget is that in Eclipse targets can be associated with different
icons:

    * better - Target-icon in Outline View: the description attribute changes the icon to
filled vs. unfilled if absent
    * weaker - Macrodef-icon in Outline View: the description attribute does not change the
icon

I can therefore use the description attribute for all public and test APIs and leave it off
for all private APIs.

CONCERNS ABOUT MACRODEF LIMITATIONS

I'm concerned that there are things that will fail if called by macrodef that wouldn't fail
if called by runtarget.  I seem to 
recall something about nested something or other or dealing with parameter substitution...
I can't recall, it was something I 
googled somewhere.  This is just a worry... if I'm wrong, please let me know.

GENERAL

Are there any things that I won't be able to do with macrodef that I could do with runtarget
(and the other way around)?  Also, are 
there any performance considerations to prefer one over the other?  How significant are they?

Because of the syntax and Eclipse issues above, I tend to prefer runtarget over macrodef for
zero-argument functions.  Is there any 
compelling reason to argue against using runtarget given the assumptions above?

Enjoy,
Steve Amerige
SAS Institute, Deployment Software Developer


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


Mime
View raw message