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,123 of 33,346   
   James K. Lowden to Alf P. Steinbach   
   Re: Why is there no input value optimiza   
   12 Apr 12 12:46:39   
   
   From: jklowden@speakeasy.net   
      
   On Tue, 10 Apr 2012 11:14:08 -0700 (PDT)   
   "Alf P. Steinbach"  wrote:   
      
   > Ideally there should   
   > be "in", "out" and "in-out" designators as in Ada   
      
   We almost have that now, right?   
      
   in:  value or const reference   
   out: reference   
   in/out: reference   
      
   The last doesn't deserve distinction.  It's rarely used because it's   
   rarely justified.   
      
   Were "in/out" syntax part of the language, the programmer has to learn   
   and use it, and the compiler has to enforce it.  Yet it's hardly used.   
   For instance, there's barely one in/out parameter in the STL.   
   std::string::swap() is one uncommon example.  I can't think of any that   
   don't involve some kind of similar buffer replacement.  Nothing in   
    uses in/out parameters.   
      
   The best functions are true functions: one output generated from N   
   inputs. Sometimes, because of the way C++ is defined, the output takes   
   the form of an output parameter instead of a return type.   (And   
   sometimes the return value is used to convey error status, but that's a   
   whole different discussion!)  Functions with in/out parameters, by   
   contrast, have side-effects by design.   
      
   --jkl   
      
      
   --   
         [ 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