Merrill Cornish wrote:

Gary,


What are the arguments in favor of not changing it?


I can't think of any language that does not evaluate all arguments to a subroutine call because invoking that subroutine. NAnt is using XML elements much like subroutine
That's not precisely correct. Every language will give up evaluating those arguments and abort the invocation of the subroutine if one of those argument evaluations throws an exception. And that's precisely the case we're talking about here.

calls where all attributes are evaluated before the element processor is 
called.  It's a fairly universal convention that shouldn't be casually tossed 
aside.

But wait, there's more: In NAnt, expression evaluation has no side effects, and in my opinion, it should stay that way for ever. Without side effects, the order of evaluation is irrelevant except for the particular case in front of us. In fact, if an attribute is never used, then whether it even gets evaluated is irrelevant. For example:

 <target name="default" bogus="${myUndefinedProperty}">
    <echo message="This target worked." />
 </target>

works fine (but if you change the 'bogus' attribute to 'description', it fails).

So the reason that it's safe to toss aside the convention you describe is that it doesn't matter. It won't affect anything or break anything, unless there is someone with some bizarre reason for wanting the build exception to get thrown instead of being avoided through the use of an 'if' or 'unless' attribute. That case is sufficiently off the wall that I think we can ignore it, at least until someone comes up with a compelling example. The only other impact is that it would add another concrete reason for prohibiting side-effects in NAnt expressions - but such a reason already exists. (Specifically, XML processors don't need to guarantee that the physical order of attributes is maintained in any way.) I conclude that instituting the general rule, namely that 'if' and 'unless' attributes get evaluated before others, is safe.


What people are expecting here is that the if-attribute of various NAnt 
elements is really a shorthand notation for an if-element wrapper around the 
statement.  Trying to mandate that usage would be a real kludge.

I'm not sure what you mean by "mandate that usage." No one is forcing people to use the 'if' or 'unless' attributes, nor do I see it being a kludge. The 'if' and 'unless' attributes on tasks_are_ shorthands for the <if> element wrapper - again, with the lone exception of the case before us. These attributes on targets are semantically a bit more complicated than an <if> wrapper, but the net effect is the same.

Gary



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to