Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #94906

Re: Request comments - printx

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: Request comments - printx
Date 2016-10-16 20:37 +1300
Message-ID <e6gp2hF15saU1@mid.individual.net> (permalink)
References <kfnh98e7nxs.fsf@x-alumni2.alumni.caltech.edu> <e6ge41Fu8usU2@mid.individual.net> <kfn60os69nb.fsf@x-alumni2.alumni.caltech.edu>

Show all headers | View raw


On 10/16/16 08:22 PM, Tim Rentsch wrote:
> Ian Collins <ian-news@hotmail.com> writes:
>
>> On 10/15/16 08:03 AM, Tim Rentsch wrote:
>>> I am soliciting comments and suggestions for a small family of
>>> functions (and a few supporting macro and type definitions) which
>>> I have taken to calling "printx", with printx() being the
>>> representative function of the family.
>>
>> This looks really interesting and I like the way you have kept
>> things well within the spirit of printf.
>
> Thank you, that is nice to hear.
>
>> Do you have a reference implementation written?
>
> Yes, modulo some finishing touches near the edges.  The examples
> I showed were all run through that implementation.  Also it
> passes all the cases in my little test suite, which is currently
> somewhere between 40 and 50 cases.  (I'm not going to say whether
> the tests were written first. :)

It might be more fun to publish the tests rather than the code to see 
what other can come up with :)

>> I assume you would also consider an equivalent "scanx"?
>
> I would consider it, sure.  Having said that, *scanf() is a very
> different kind of beast, and I'm not sure how the printx() ideas
> would map onto scanx().  The first order of business is to get
> printx() finalized and wrapped up;  after that's done we can
> come back to what might work for scanx().

I guess the obvious use case is to read back in what printx() writes 
out: data serialisation.

> Do you have any other comments or suggestions for what additional
> functionality to make available, or how?  One thing I know it
> would be nice to be able to do but I'm not sure how is passing
> flags along in a printx_send() call.  For example, in the complex
> number formatters, it would be nice to be able to pick up the
> flag characters in the original %! conversion, and use those
> flags on the two components of the complex number.  There is an
> obvious way to do that, by constructing a format string for the
> call to printx_send(), but that's a bit heavy-handed - I am
> hoping for some better idea(s) about how to arrange such things.

Well you could do something along the lines of setting the state of your 
Channel object if you had something analogous to fprintf() or you allow 
the state of stdout to be manipulated.  That's the (admittedly clunky) 
way C++ stream manipulators are used to set output formatting such as 
precision and representation.  Although in this case you would have to 
use multiple printx() calls if you wanted to use differing 
representations for each parameter.

-- 
Ian

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-14 12:03 -0700
  Re: Request comments - printx supercat@casperkitty.com - 2016-10-14 13:06 -0700
    Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-15 15:28 -0700
      Re: Request comments - printx supercat@casperkitty.com - 2016-10-17 10:26 -0700
        Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-18 08:42 -0700
          Re: Request comments - printx supercat@casperkitty.com - 2016-10-20 09:12 -0700
            Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-22 19:23 -0700
  Re: Request comments - printx Ian Collins <ian-news@hotmail.com> - 2016-10-16 17:30 +1300
    Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-16 00:22 -0700
      Re: Request comments - printx Ian Collins <ian-news@hotmail.com> - 2016-10-16 20:37 +1300
        Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-17 11:22 -0700
  Re: Request comments - printx BartC <bc@freeuk.com> - 2016-10-16 23:44 +0100
    Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-17 10:29 -0700
      Re: Request comments - printx BartC <bc@freeuk.com> - 2016-10-17 18:57 +0100
        Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-18 08:20 -0700
          Re: Request comments - printx Nick Bowler <nbowler@draconx.ca> - 2016-10-19 17:10 +0000
            Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-20 08:58 -0700
              Re: Request comments - printx raltbos@xs4all.nl (Richard Bos) - 2016-10-23 13:37 +0000
                Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-23 14:16 -0700
  Re: Request comments - printx Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-10-18 02:41 -0700
    Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-18 08:37 -0700
      Re: Request comments - printx Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-10-18 08:45 -0700
      Re: Request comments - printx Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-10-18 09:46 -0700
        Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-18 23:33 -0700
  Request comments - printx asetofsymbols@gmail.com - 2016-10-23 00:39 -0700
    Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-23 14:08 -0700
  Re: Request comments - printx Richard Heathfield <rjh@cpax.org.uk> - 2016-11-09 16:32 +0000
    Re: Request comments - printx "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-10 01:03 +0800
    Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-11-12 17:53 -0800
      Re: Request comments - printx Richard Heathfield <rjh@cpax.org.uk> - 2016-11-13 16:43 +0000
        Re: Request comments - printx Tim Rentsch <txr@alumni.caltech.edu> - 2016-11-15 10:37 -0800

csiph-web