Boost logo

Boost :

From: Jake Voytko (jakevoytko_at_[hidden])
Date: 2007-07-12 15:05:39


Perhaps "Standard" was a bad term, but rather, "Boost accepted". While
perusing the Boost.Bimap docs, I found that the following syntax is allowed
for defining a Bimap:

  typedef bimap<int,std::string> bm;
  bm b = list_of< bm::relation > (1,"one") (2,"two") (3,"three");

http://cablemodem.fibertel.com.ar/mcape/boost/libs/bimap/boost_bimap/bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_assign

And I found that this felt like a natural way to define pairs. Looking over
my syntax again, it doesn't appear to have any specific advantages over your
proposal (except alternative syntax, which I won't list as an advantage).

It does strike at my major concern, which is the ability to generically
parse XML documents. I feel the proposals that set up compile-time
invariants for building XML documents would require a lot of thought in this
area.. how is the document tree best represented during a read? Does the
compile-time check exist solely to build the document, and have a different
internal structure? Or can it be used to validate an article that is read
(to use the above example)? Consider my example an expression of support for
either a declarative syntax, or a C++ map/push_back() syntax as Phil
Endecott suggested.

My opinion is that if the writer has specific needs as far as document
structure is concerned, they can make a class that uses its own compile time
invariants for building a document (using Boost.XML to literally write the
document), and can use runtime checks when parsing a document. To me,
requiring that "authors" exist under "articleinfo"s, for instance, is a
member of a problem domain more restrictive than XML worries about, so
Boost.XML should not worry about it.

Jake

On 7/12/07, David Abrahams <dave_at_[hidden]> wrote:
>
>
> on Wed Jul 11 2007, "Jake Voytko" <jakevoytko-AT-gmail.com> wrote:
>
> > Splitting the difference (or so I hope) between easy
> trees/expressiveness
> > and standard syntax, how about something like this?
> >
> > root.push_front
> > (
> > tag("Article Info",
> > (title ? (comment("This title was moved"), title) : NULL)
> > (tag("author",
> > (tag("firstname", "Joe"))
> > (tag("surname", "Random"))
> > ))
> > )
> > );
>
> How does that improve things?
> What do you mean by "standard syntax?"
>
> --
> Dave Abrahams
> Boost Consulting
> http://www.boost-consulting.com
>
> The Astoria Seminar ==> http://www.astoriaseminar.com
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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