tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

make: +=-assigning (to) an empty value



There is an ancient PR of mine (toolchain/46750) regarding use of the 
=+ assignment operator and empty values.

For the most part of it, I agree that make's behaviour is OK as soon as you 
realize that there are no lists in make, only that strings can be interpreted 
as a list of space-seperated words that itself can't contain spaces.

If we also accept that these lists can't contain empty elements (e.g. 
"foo  bar" has two elements "foo" and "bar" and not three "foo", "" and "bar") 
there still are two cases in which it could make sense to change make's 
traditional behaviour:

1. +=-assigning to an empty value:
	FOO= # empty
	FOO+= bar
gives you FOO=" bar".
If you think of FOO+=bar as "append the value bar to the list FOO" (and not as 
"append the string bar, seperated by a space, to the sting in FOO"), then it 
may make more sense to have FOO="bar" afterwards.
So, would it make sense to have += not append a space to an empty value?

2. +=-assigning an empty value
	FOO= bar
	FOO+= # empty
gives you FOO="bar ".
Again, if you think of += as appending list elements (think of that # empty 
as ${BAR} happening to be empty), it may make more sense to have FOO="bar" 
afterwards.
So, would it make sense to have += do nothing if the value to append is empty?

Can anyone think of an existing usage of += these changes could break?


Home | Main Index | Thread Index | Old Index