[QBS] Increasing verbosity of targetOS-based on conditions in user code

Joerg Bornemann joerg.bornemann at digia.com
Thu Jun 13 12:22:20 CEST 2013


On 13/06/2013 09:37, Alberto Mardegan wrote:
> On 06/13/2013 10:02 AM, Joerg Bornemann wrote:
>> Is it really worth it, given that we want extend Array to have a
>> contains method anyway, which would make the code less verbose again?
>
> I find
>    condition: qbs.targetOS.contains("windows") ||
>               qbs.targetOS.contains("darwin")
>
> much more readable than a "filter" property. Do you plan to allow the
> contains() method to receive a list of parameters in order to make the
> above even shorter,

No, because it's not obvious which boolean operator would be used for 
the parameter list.
Is foo.contains("A", "B") equivalent to (foo.contains("A") || 
foo.contains("B")) or is it rather (foo.contains("A") && foo.contains("B"))?

> or would it be possible to write something like:
>
>    condition: qbs.targetOS in ["windows", "darwin"]
>
> ?

There is no operator overloading in JavaScript.
And the in-operator works on keys, not on values.
If we make targetOS a set then this would be possible:
targetOS: {"windows" : 1, "darwin" : 1}
...
if ("windows" in qbs.targetOS)
     doSomethingWindowsSpecific();


BR,

Joerg



More information about the Qbs mailing list