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

Re: [HTCondor-users] class ad logic with undef (non-)equal

Hi TJ,

thanks for the explanation!
Then I will stick to
  regexp("strfoo", MyAdd ?: "" )
to avoid any undefined corners.

Cheers and thanks,

On 12/05/2021 16.13, John M Knoeller wrote:
Yes, the ?: "operator" works when the first argument is a function, so

 Â Âfn(x) ?: y

will return the result of evaluating fn(x) if it isn't undefined and y otherwise. But you need to write the expressions so that if f(x) is a boolean then y is also a boolean. Âso this

 Âregexp("strfoo",MyAdd) ?: ""

Should probably be this instead

 Âregexp("strfoo",MyAdd) ?: false

Or you could put the ?: inside the function call to make sure that the regular expression check never returns undefined

 Âregexp("strfoo", MyAdd ?: "" )


*From:* HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> on behalf of Thomas Hartmann <thomas.hartmann@xxxxxxx>
*Sent:* Wednesday, May 12, 2021 7:27 AM
*To:* HTCondor-Users Mail List <htcondor-users@xxxxxxxxxxx>
*Subject:* [HTCondor-users] class ad logic with undef (non-)equal
Hi all,

a short `undef` logic question:

I wrote a statement like
 ÂÂ ( Expr1 || regexp('strfoo',MyAdd) ) != true

Unfortunately, I had assumed, that the regexp macro should always
resolve to
 ÂÂ ( Expr1 || true/false ) != true
but Kruno pointed out, that in case the ad is undef the macro is not
defined as well - which would result in
 ÂÂ undef != true

So, one question would be, if there is a `?`-like operator for a boolean
non-equal comparison, that resolves in false when compared to undef?

To catch undef cases, we are going now for
 ÂÂ ( Expr1 || regexp('strfoo',MyAdd) ? : "" ) ) != true
but we are not sure, if `?` as operator actually catches undefs here?

 ÂÂ Thomas

HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting

The archives can be found at:

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature