I thought the output of this code would be
Hello World 1
Hello World 2 3
But I get
Hello World 1
Hello World 2 Hello World 3
Here's the jam code
rule weird ( a : b + : c * : d ? )
{
echo "Hello World $(a)" ;
echo "Hello World $(b)" ;
}
weird 1 : 2 3 ;
Jam's variable expansion rules are very different from other languages. From the boost jam documentation:
The result of a token after variable expansion is the product of the components of the token, where each component is a literal substring or a list substituting a variable reference.
So jam is expanding "Hello World $(b)" to "Hello World $(b[1])" "Hello World$(b[2])" and echoing that.
If you want "Hello World 2 3", you need to split the echo argument into two tokens
echo "Hello World" $(b) ;