From: jklowden@speakeasy.net   
      
   On Sat, 14 Apr 2012 23:27:49 -0700 (PDT)   
   Dave Abrahams wrote:   
      
   > If you want to live in a   
   > world where you can dismiss mutation of state as rare, you should be   
   > programming in Haskell. (**)   
      
   I didn't mean to imply that mutation is rare. I meant to state that   
   the syntax and idiom of C++ makes the use of i/o parameters --   
   syntactic, explicit parameters -- rare. Not vanishingly rare, but rare   
   enough that I see no need for them to expressly denoted in the syntax.   
   I do not think   
      
    void swap ( string& str );   
      
   would be improved by any form of   
      
    void swap ( string& str [io] );   
      
   Not only that, but the language offers alternatives to i/o   
   parameters that are better in most cases.   
      
   Looking at Jonathan Thornburg's reasonable example   
      
   > sqrt_of_big_vector(std::vector& v);   
      
   it might also be expressed as   
      
    sqrt_of_big_vector(v.begin(), v.end());   
   or   
    transform(v.begin(), v.end(), v.begin(), sqrt);   
   or   
    big_vector::sqrt()   
      
   depending on whether or not function is applied element-wise. I think   
   you'll agree the last version is preferable if, for reasons of   
   internal consistency, the operator must be an all-or-nothing   
   transformation.   
      
   Acknowledged, Jonathan's version also works. The OO school says   
   functions that act on one type should be members. (Why, then, does the   
   STL have a sort function? Because it works on POD types, which   
   themselves exist because, as Stroustrup likes to remind us, C++ isn't   
   only an OO language.)   
      
   > > I think it's notable, actually, that the STL does   
   > > not provide sort>.   
   >   
   > What in particular do you think is notable about it?   
      
   It's notable because the committee evidently felt it was   
   redundant, insofar as the standard was released (and presumably   
   considered complete) without it. Because acting on the whole set is a   
   specific case of acting on a subset, the STL satisfies both by providing   
   just the general interface. By example it encourages others to do the   
   same.   
      
   > the committee is actively considering adding it.   
      
   If you have a favorite paper explaining why we we need a function like   
   that, I'd be interested to read it.   
      
   Like you, I was younger when the STL first made its appearance. ;-)   
   I thought the lack of stuff like sort> was an obvious   
   oversight, and I wrote lots of little wrappers for them. Over the   
   years, as you might guess, I stopped bothering. I know, it's possible   
   to pass the begin() of one container and the end() of another. Very   
   exciting, too! And, since I haven't made that particular mistake in 10   
   years, I'm probably due for one.   
      
   > (**) Which isn't to say you're unwelcome here in C++-land, of   
   > course :-)   
      
   Thanks, I appreciate that. The whole point of hanging out on the   
   usenet is to have interesting discussions and learn stuff. Which,   
   come to think of it, is quite a bit like mutable state. Wait, I'm a   
   variable? I thought I was an algorithm!   
      
   Regards,   
      
   --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)   
|