On May 15, 2009, at 5:08 PM, Steve Appling wrote:
John Murph wrote:
I still have one reservation about this new syntax.
On Fri, May 15, 2009 at 2:31 AM, Adam Murdoch <[email protected]
<mailto:[email protected]>> wrote:
<clip ...>
For me, this is the big problem with the new syntax. The <<
operator have such a HUGE importance to meaning, and yet being very
non-obtrusive syntactically causes me concern. Especially if one
uses different coding styles. For instance:
task doSomething {
configurationIt
config SomeMore
}
task notAgain << {
println 'You are not supposed to call me'
}
Especially when you have tasks that are many lines long this is
O.K., but not great. However, we have a coding standard that puts
the { on a new line, such that it becomes
task doSomething
{
configurationIt
config SomeMore
}
task notAgain <<
{
println 'You are not supposed to call me'
}
The trailing << on the second task line just seems too easy to
overlook, and yet is quite meaningful to the behavior of the
script. This is why I would like (at least an option) for
task notAgain.do
{
println 'You are not supposed to call me'
}
As said in the other mail, you have this option, but with parentheses.
And right now you have to use doLast. We will discuss whether we
should introduce a do method delegating to doLast.
While I agree that they are confusingly similar, I'm not sure that
the .do is any more obvious than the trailing <<.
I'm not sure of a better solution here. I have noticed myself
making mistakes while converting our project over to use the new
syntax. Perhaps I'm just slow, but I have already mixed up task and
configuration closures a few times myself.
On the other hand mixing things up happened to me also pretty
frequently with the old syntax. Specially when I have created tasks
with a custom type.
Previously if you had to do configuration on a newly created task
you had to call configure explicitly like:
createTask('myTask', type:Copy).configure { config here }
Existing tasks could be configured directly, however:
myTask { config here }
I don't think this was previously intended to be a feature, but it
did distinguish the use of the closure.
One thing I like with the new DSL is that we have consistency in
regard to the syntax for configuring and adding actions. This is no
longer context dependent. Of course you could do configuration more
heavyweight to make it more expressive.
With the new syntax you can still do (which is nicer than the above
IMO):
task(myTask, type: Copy).configure {
<configure>
}
- Hans
--
Hans Dockter
Gradle Project Manager
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email