Boost logo

Boost :

Subject: Re: [boost] Formal Review of Proposed Boost.Process library
From: Max Sobolev (macsmr_at_[hidden])
Date: 2011-02-21 07:43:02


On 20.02.2011 1:49, Artyom wrote:
> I would strongly disagree with that. C++ is too "cryptic"
> enough so having simple, clear and readable interfaces
> for average programmer is very critical.

Which code is simpler and more clear?

   auto pipe = ls [--arg("reverse") % -arg('l') % "/usr/lib"] | grep
["^d"];
   pipe();

or:

   struct redirect_to
   {
     explicit redirect_to(boost::process::handle h) : h_(h) {}

     boost::process::stream_ends operator ()
(boost::process::stream_type) const
     {
       return boost::process::stream_ends(h_, boost::process::handle());
     }

   private:
     boost::process::handle h_;
   };

   template<typename T> T identity(T value) {return value;}

   // somewhare in main():

   process::stream_ends ends = process::behavior::pipe()
                                   (process::output_stream);

   std::string ls_path = process::find_executable_in_path("ls");
   std::vector<std::string> ls_args =
       boost::assign::list_of("--reverse")("-l")("/usr/lib");

   process::context ls_ctx;
   ls_ctx.streams[process::stdout_id] =
                boost::bind(identity<process::stream_ends>, ends);
   process::child ls = process::create_child(ls_path, ls_args, ls_ctx);

   std::string grep_path = process::find_executable_in_path("grep");
   std::vector<std::string> grep_args = boost::assign::list_of("^d");
   process::context grep_ctx;
   grep_ctx.streams[process::stdin_id] = redirect_to(ends.parent);

   process::child grep = process::create_child(grep_path,
                                               grep_args, grep_ctx);

(...a rhetorical question)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk