From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,496108d9dbc25896 X-Google-Attributes: gid103376,public From: Ehud Lamm Subject: Re: printf package/Function/Procedure in Ada ?? Date: 1999/03/10 Message-ID: #1/1 X-Deja-AN: 453314544 References: <7c4e75$e5m@drn.newsguy.com> <36e5ee34.38268278@news.pacbell.net> <36E61F72.4C68BE6C@rocketmail.com> Content-Type: TEXT/PLAIN; charset=US-ASCII Organization: The hebrew University of Jerusalem Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-03-10T00:00:00+00:00 List-Id: On Wed, 10 Mar 1999, Corey Ashford wrote: > Tom Moran wrote: > > > > Isn't > > Put("I=" & integer'image(i) & name); > > simpler than > > printf("I=%i%s", i, name); > > Except that printf allows you to more easily get fancy with formatting of > the variables, e.g. %08x, or %7.3f. You can do this kindof thing with > text_io, but it's a lot more keystrokes. > > In general, I think formatted I/O is a little more difficult in Ada, but Ada provides > many things that C can't do easily or at all (e.g. string slices, 'image for enumerated > types). > I think the real problem is input not output. In Ada you have to "parse" fileds in the input semi manually, where as scanf does it for you. I know scanf sucks in many respects, but sometimes its behind the scenes work is very valuable. Writing scanf in Ada is conceptually problematic - since as opposed to output, in input you really don't have any clues as to the types that may exist in the input stream. My best conceptual solution (this means I haven't really coded it yet) is to have something like this: Int1:=To_Integer(Get_Field()) Where Get_Field is overloaded by type but all other params (like width) are standard. It always returns String (or something like it). The conversion stays the responsibility of the caller. Better ideas are more than welcome. Ehud Lamm mslamm@pluto.mscc.huji.ac.il http://purl.oclc.org/NET/ehudlamm <== Use PURL to find me!