From: nobu.nokada@... Date: 2004-06-24T12:04:45+09:00 Subject: Re: Cleaning up IO#popen Hi, At Wed, 23 Jun 2004 02:49:26 +0900, evanm@frap.net wrote in [ruby-talk:104358]: > > > it work? What is its args? Does it drop the '-' and mode arguments? > > > > I'm not sure they are really evil. > > Parsing a string for magic arguments moves logic from the code into the data. > It's poor design. Why not have a separate function with all the benefits that > brings? AFAIK there aren't any benefits in parsing magic values from a > string, but if you allow "-" then the programmer has to special case every > string he passes to verify that it's not "-" or risk running the wrong > function. > > There are many more elegant ways of doing this, but the best is to not do it > at all. I admit there will be better ways much. But I'd like to introduce a new class for child process rather than popen3. > > At Mon, 21 Jun 2004 06:06:02 +0900, > > evanm@frap.net wrote in [ruby-talk:104194]: > > > * takes a "mode string" arg for what really should be a separate function > > > * takes a "-" as a magic value for what really should be a separate function > > > > Do you suggest to provide all possible combinations? > > I suggest the code I submitted for IO.fork_open. There are only two > options, reading and writing, and this can be done in one with my > implementation of IO.fork_open which provides a bidirectional pipe. Single pipe pair cannot be used for bidirectional, and fork_open doesn't feel a good name for me. -- Nobu Nakada