Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-09-21 04:29:29


Vladimir Prus wrote:
>Reece Dunn wrote:
>
> > Vladimir Prus wrote:
> >>There are some things I don't like. First, as many mentioned, the naming
> >>is not optimal.
> >>[snip]
> >>or maybe even
> >>
> >> ("[" + io(v)/"," + "]")
> >>
> >>for nested formats, something like
> >>
> >> ("["
> >> + io::format(
> >> "(" + io::format()/":" + ")"
> >> )/","
> >> +
> >> "]"
> >> )
> >>
> >>These are just ideas, though.
> >
> > In my development version, I now have this working! That is, you can do:
> >
> > std::cout << io::object
> > (
> > std::make_pair( 'a', 5 ),
> > "{ " + fmt::pair()/" == " + " }"
> > ) << '\n'; // output: { a == 5 }
>
>Great. I wonder what others think? Personally, I really like the /
>operator.
>Probably that's because I've borrowed the idea from one parser generator
>which allows to write:
>
> (literal / "," )
>
>to mean a list of literals separated by ",".

Sure. Another alternative would be:

   fmt::pair()[ " = " ]

but this may be confusing WRT the standard behaviour of the [] operator.

>The opening and closing braces look less clear for me now. Maybe, we can
>use
>
> fmt::pair("{", "}")/" == "

The problem with this is deducing that the parameters passed to fmt::pair or
others are format objects (for formatting first and second data members) or
delimiter strings or other arguments (e.g. DelimiterType or array length).
This could possibly be done using MPL, but would further complicate the
implementation.

>or
>
> fmt::braces("{", "}") + fmt::pair()/" == "
>
>But I'm really really not sure.

Suggestions are always welcome.

fmt::braces is openclose_formatter in the review implementation
(wrapper_decorators in the version I am currently working on). The problem
with defining operator + for <open_close> + <open_close_separator> value
holders is: how do you inherit values, for example:

   fmt::braces( "<< ", " >>" ) + fmt::pair( "{ ", " }" )/" == "

is this: << a == b >>
or: { a == b }

This would be "<< a == b >>" in this instance, because fmt::pair will set
the values and fmt::brace will cause them to be overrided. This is similar
to this situation:

   "<< " + fmt::pair().decorate( "{ ", " }" )/" == " + " >>"

Also, MW CodeWarrior 9.2 is complaining about the above:

typedef boost::io::sequence_decorators<char> decorators;

### mwcc Compiler:
# 122: = "<< " + decorators() / " :: ";
# Error: ^
# illegal operands 'boost::io::sequence_decorators<char>' / 'const char *'

I will need to investigate this further.

Regards,
Reece

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo


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