From: cross@spitfire.i.gajendra.net   
      
   In article <68a3b980$0$713$14726298@news.sunsite.dk>,   
   Arne Vajhøj wrote:   
   >On 8/18/2025 7:27 PM, Dan Cross wrote:   
   >> In article <68a3b334$0$713$14726298@news.sunsite.dk>,   
   >> Arne Vajhøj wrote:   
   >>> On 8/18/2025 3:42 PM, Arne Vajhøj wrote:   
   >>>> On 8/18/2025 8:37 AM, Simon Clubley wrote:   
   >>>>> 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 agree with the philosophy in general.   
   >>>>   
   >>>> But I have little faith in trying to translate from one language   
   >>>> to another language without deep understanding of operators in the   
   >>>> two languages.   
   >>>   
   >>> As warning:   
   >   
   >>> $ cc op   
   >>> $ link op   
   >>> $ run op   
   >>> 2 1   
   >   
   >>> $ pas op   
   >>> $ lin op   
   >>> $ run op   
   >>> 2.50000E+00 1   
   >>   
   >> Of course. In pascal, integer division is spelled, `div`, not   
   >> `/`. Why would one expect otherwise?   
   >>> $ for op   
   >>> $ lin op   
   >>> $ run op   
   >>> 2 0   
   >>   
   >> Here, FORTRAN has type promotion rules that require one of the   
   >> operands of the `/` binary operator to be of a real type before   
   >> the operation is performed as a real. iv/2.0 would give the   
   >> floating point result, for FORTRAN-77 and later.   
   >>   
   >> And of course, `iv mod 2` should be, `mod(iv, 2)`.   
   >   
   >Yes.   
   >   
   >But point is that one need to know something about the   
   >languages.   
   >   
   >Just picking an operator that "looks like" and hope it   
   >has similar semantics is no good.   
      
   This seems like a very extreme example. There is a scale of   
   knowledge when it comes to programming languages, from the basic   
   ways in which one does various things like write loops or   
   perform basic arithmetic, to the minutia of specific library or   
   IO routines, with semantics of specific operators and how they   
   combine probably somewhere in the middle.   
      
   I happen to disagree with Simon's notion of what makes for   
   robust programming, but to go to such an extreme as to suggest   
   that writing code as if logical operators don't short-circuit   
   is the same as not knowing the semantics of division is   
   specious.   
      
    - Dan C.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|