From: johnrreagan@earthlink.net   
      
   On 8/15/2025 9:55 AM, Arne Vajhøj wrote:   
   > On 8/15/2025 9:40 AM, John Reagan wrote:   
   >> On 8/15/2025 9:35 AM, Arne Vajhøj wrote:   
   >>> On 8/15/2025 8:27 AM, Simon Clubley wrote:   
   >>>> On 2025-08-12, Arne Vajhøj wrote:   
   >>>>> Code:   
   >>>>>   
   >>>>> #include    
   >>>>>   
   >>>>> #include    
   >>>>>   
   >>>>> my_bool demo_init(UDF_INIT *initid, UDF_ARGS *args, char *message)   
   >>>>> {   
   >>>>> if(args->arg_count == 2 && args->arg_type[0] == STRING_RESULT   
   &&   
   >>>>> args->arg_type[1] == INT_RESULT)   
   >>>>   
   >>>> Is it guaranteed that arg_type[] will always have at least elements ?   
   >>>> If not, that's dangerous unless the compiler you are using does   
   >>>> expression short-circuiting.   
   >>>   
   >>> Isn't C required to do short circuiting on && ?   
   >>   
   >> Yes, C and C++ short-circuits. Other languages may not. For example,   
   >> Pascal does promise short-circuit which is why our Pascal also provides   
   > ^not> an AND_THEN and OR_ELSE operator much like   
   you find   
   > in Ada.   
   >   
   > VB.NET has AndAlso and OrElse.   
   >   
   > But I believe most curly bracket languages inherited from   
   > C in this regard.   
   >   
   > Arne   
   >   
   Thanks for the correction. Yes "not promise".   
      
   BTW, BLISS does not promise short-circuit. And in the true BLISS   
   fashion, most of us use the following macros   
      
    ! AND_THEN(B1,B2,...Bn) returns TRUE if all of Bi are TRUE.   
    ! Evaluates the Bi left to right and stops on the first false one.   
    !   
    AND_THEN(B)[]=   
    %IF %LENGTH EQL 1   
    %THEN   
    (B)   
    %ELSE   
    (IF (B) THEN AND_THEN(%REMAINING) ELSE FALSE)   
    %FI %,   
      
    ! OR_ELSE(B1,B2,...Bn) returns FALSE if all of Bi are FALSE.   
    ! Evaluates the Bi left to right and stops on the first true one.   
    !   
    OR_ELSE(B)[]=   
    %IF %LENGTH EQL 1   
    %THEN   
    (B)   
    %ELSE   
    (IF (B) THEN TRUE ELSE OR_ELSE(%REMAINING))   
    %FI %,   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|