From: clubley@remove_me.eisner.decus.org-Earth.UFP   
      
   On 2025-08-15, Arne Vajhøj wrote:   
   >   
   > In general I like the idea of writing code in a way that does   
   > not require the reader to have memorized ten thousand things from   
   > the language spec.   
   >   
   > But I do not consider this a matter of remembering the specific   
   > details about an operator - I consider this a matter of remembering   
   > what operator a symbol represent.   
   >   
   > I consider "short circuiting AND" and "non short circuiting AND"   
   > to be two different operators.   
   >   
      
   They are not. One is a subset of the other and both carry out the   
   same core operation.   
      
   > And in C then && is the first operator not the second operator.   
   >   
   > And understanding what operator each symbol represent is not   
   > detail but core. IMHO.   
   >   
      
   I disagree. Strongly. Both operators do exactly the same thing which   
   is to implement a logical AND. Code written using this operator   
   generates exactly the same logical AND result regardless of whether   
   short circuiting is in use or not.   
      
   In addition however, a short circuiting compiler generates code to   
   stop evaluation if the previous logical AND subexpression was false.   
   This is a feature of the compiler and does not turn logical AND into   
   something which does something other than logical AND.   
      
   It is _always_ safe to write code which assumes short circuiting is   
   not in use and it will work exactly the same even in the presence   
   of a compiler which generates short circuiting code.   
      
   It's all about writing robust code, not clever code. My approach   
   generates much more robust code, especially when you might translate   
   the code to another language that does not implement short circuiting   
   and you don't realise this during the translation.   
      
   I prefer that approach to having to maintain a fragile matrix in my   
   head of what specific language or compiler implements short circuiting   
   and which do not.   
      
   Simon.   
      
   --   
   Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP   
   Walking destinations on a map are further away than they appear.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|