Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!aramis.rutgers.edu!paul.rutgers.edu!carroll
From: carroll@paul.rutgers.edu (V. I. Lenin)
Newsgroups: comp.lang.c++
Subject: Re: Questions on I/O in 2.0
Message-ID: 
Date: 3 Oct 89 16:02:58 GMT
References: <499@bthpyd.UUCP> <8496@ardent.UUCP>
Distribution: na
Organization: Rutgers Univ., New Brunswick, N.J.
Lines: 31

In article <8496@ardent.UUCP> jss@jra.ardent.com (Jerry Schwarz (Compiler)) writes:

> ..."form" is not a good C++ interface for I/O.  
> It isn't type safe and it isn't easily extensible.  If you like
> a stdio interface. The same effect is easily accomplished by sprintf'ing 
> into a buffer and using the char*...

I think Jerry missed a good opportunity to brag about his iostreams.
The reason you don't need "form" in 2.0 is not because you can emulate
it with sprintf, but rather because you can do it much better with
ostrstreams.  Example:

        int i;
        char *s;
        T t;
        char *printString;

Using form:
        printString = form("i is %d, s is %s", i, s);

Using an ostrstream:
        ostrstream os;
        os << "i is " << i << ", s is " << s << ", t is " << t;
        printString = os.str();

Notice that using an ostrstream makes in-core I/O just as uniform and
extensible as external I/O.  And as Jerry points out, you don't need
all that printf-style "%-5s" field qualifier stuff, you can do it all
much more cleanly with iostream manipulators.

martin