Re: [classad-users] Newbie Question: Evaluation of logicalexpressions


Date: Mon, 4 Feb 2002 09:17:42 -0600 (CST)
From: Alain Aslag Roy <roy@xxxxxxxxxxx>
Subject: Re: [classad-users] Newbie Question: Evaluation of logicalexpressions
>First of all, I don't understand your reference to operators.h.

Sorry, I meant operators.C

>I'm looking at
>src/condor/condor_classad/operators.h, and all I see is a big enum declaration

That's old ClassAds, as is your example below.

>     // test for cases when evaluation is strict w.r.t. "error" and 
> "undefined"
>     if (op != META_EQUAL_OP && op != META_NOT_EQUAL_OP  &&
>         op != LOGICAL_OR_OP && op != LOGICAL_AND_OP     &&
>         op != TERNARY_OP)

In the new operators.C, I see:

Evaluate (EvalState &state, Value &result) const
{
     Value   val1, val2, val3;
     bool    valid1, valid2, valid3;
     int     rval;

     valid1 = false;
     valid2 = false;
     valid3 = false;

     // Evaluate all valid children
     if (child1) {
         if( !child1->Evaluate (state, val1) ) {
             result.SetErrorValue( );
             return( false );
         }
         valid1 = true;
     }

     if (child2) {
         if( !child2->Evaluate (state, val2) ) {
             result.SetErrorValue( );
             return( false );
         }
         valid2 = true;
     }
     if (child3) {
         if( !child3->Evaluate (state, val3) ) {
             result.SetErrorValue( );
             return( false );
         }
         valid3 = true;
     }

     rval = _doOperation (operation, val1, val2, val3, valid1, valid2, valid3,
                 result, &state );

     return( rval != SIG_NONE );
}

So all operands, are evaluated before the operation, right?

Your point about the lack of side-effects and how things are evaluated is a 
good point though.

-alain




[← Prev in Thread] Current Thread [Next in Thread→]