home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,823 of 33,346   
   Zeljko Vrba to James K. Lowden   
   Re: iostream replacement   
   26 Jan 13 10:17:27   
   
   From: mordor.nospam@fly.srk.fer.hr   
      
   On 2013-01-25, James K. Lowden  wrote:   
   > On Thu, 24 Jan 2013 23:59:38 -0800 (PST)   
   > fmatthew5876  wrote:   
   >   
   >   
   >> first example of operator overloading abuse.   
   >   
   > Define abuse, please.   
      
   This has bitten me more than once:   
      
     cout << modify_x() << x << endl;   
      
   Unspecified evaluation order of function arguments.  It's something that I'm   
   normally aware of while calling ordinary functions.  Here, the context and   
   the operator conspire to mislead one to believe that left-to-right   
   sequencing will take place, whereas it does not; the compiler transforms   
   this to nested function calls.   
      
   In IO, order of operations very much matters (something Haskell folks   
   realized early on) and choosing an output operator which doesn't introduce a   
   sequence point between each two items output was.. oversight at best.   
      
   In this sense, overloading comma would have been much better, though, OTOH I   
   can't remember whether user-defined comma also introduces a sequence point.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca