Boost logo

Boost-Build :

From: David Abrahams (gclbb-jamboost_at_[hidden])
Date: 2003-05-12 18:08:03


In scanning the codebase, I'm seeing stuff like this fairly often:

rule set-property-adjuster ( property-adjuster )
{
for local name in $(self.main-targets)
{
local t = [ main-target $(name) ] ;
result += [ $(t).set-property-adjuster $(property-adjuster) ] ;
}
local self-location = [ project.attribute $(self.project) location ] ;
for local pn in [ project.attribute $(self.project) projects-to-build ]
{
local p = [ project.module-name [ path.join $(self-location) $(pn) ] ] ;
local t = [ project.target [ project.attribute $(p) location ] ] ;
result += [ $(t).set-property-adjuster $(property-adjuster) ] ;
}
}

...

rule actualize ( )
{
if ! $(self.actualized)
{
self.actualized = true ;

local actual-targets ;
for local i in [ targets ]
{
actual-targets += [ $(i).actualize ] ;
}
}
}

What these rules have in common is that discarded (often empty)
results of indirect rule invocations are needlessly stored in a
variable. Note that in the first case, result is not even declared
local! It seems to me the code would've been much cleaner as:

rule set-property-adjuster ( property-adjuster )
{
for local name in $(self.main-targets)
{
local t = [ main-target $(name) ] ;
$(t).set-property-adjuster $(property-adjuster) ;
}
local self-location = [ project.attribute $(self.project) location ] ;
for local pn in [ project.attribute $(self.project) projects-to-build ]
{
local p = [ project.module-name [ path.join $(self-location) $(pn) ] ] ;
local t = [ project.target [ project.attribute $(p) location ] ] ;
$(t).set-property-adjuster $(property-adjuster) ;
}
}

...

rule actualize ( )
{
if ! $(self.actualized)
{
self.actualized = true ;

for local i in [ targets ]
{
$(i).actualize ;
}
}
}

Agreement/argument?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com
 

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk