tech-userlevel archive

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

Re: make: new modifyer :Y



On Wednesday, at 22:35, David Holland wrote:
|    awk < /dev/null 'END { print ("1" == 1); }'
|    awk < /dev/null 'END { print (1 == 1.0); }'
|    awk < /dev/null 'END { print (1.0 == "1.0"); }'
|    awk < /dev/null 'END { print ("1.0" == "1"); }'
| 
|    awk < /dev/null 'END { print ("1"+0 == 1); }'
|    awk < /dev/null 'END { print (1 == 1.0); }'
|    awk < /dev/null 'END { print (1.0 == "1.0"+0); }'
|    awk < /dev/null 'END { print ("1.0"+0 == "1"+0); }'
| 
| Surprised by any of that?

If you think about it carefuly, no surprise. But here, the quotes help the ==
operator, I guess.

|  > My original idea was not to go that far and just replace the
|  > interpretation of a string in a boolean context (like in ".if
|  > ${X}") by the extended interpretation of "Yes" "1" etc.
| 
| That is exactly that far. Remember that && is also a boolean context,
| and == inherently produces a boolean value.

Yes: it produces a boolean. But arguments are strings, not booleans.
make(1) is very clear about this:
     If after variable expansion, either the left or right hand side of a `=='
     or `!=' operator is not an integral value, then string comparison is
     performed between the expanded variables.

| This doesn't actually solve the problem I outlined, unless you
| completely prohibit == on boolean values. If you do, then that
| particular problem doesn't arise... but then you need to introduce
| other syntax for comparing boolean values.

You can always compare boolean values with &&, || and !. So it would be OK to
prohibit == on booleans and leave it as it is now.

For instance, cmake has only these:

                if(<constant>)

              True  if the constant is 1, ON, YES, TRUE, Y, or a non-zero num-
              ber [...]

                if(<variable>)
                if(NOT <expression>)
                if(<expr1> AND <expr2>)
                if(<expr1> OR <expr2>)


Home | Main Index | Thread Index | Old Index