Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-07-13 16:54:39


on Thu Jul 12 2007, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:

> David Abrahams wrote:
>> on Thu Jul 12 2007, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
>>
>>>>> You're optimizing the wrong case
>>>>
>>>> I don't know about that. The kind of interface used above has
>>>> become very popular in the Python world... because it's useful. It
>>>> may not cover the entire domain of XML manipulations well, but it
>>>> does cover an important corner.
>>>
>>> Maybe it is, maybe it does. But you are still optimizing the wrong
>>> case; horrible procedural code for creating a toy XML.
>>
>> I don't understand what you're objecting to. The XML schema being
>> generated is not realistic?
>
> ...
>
>> Well, I didn't understand the point you were trying to make, whereas
>> (of course) I find my own code immediately understandable.
>
> The point I was trying to make is that when you write the XML generation
> code in a modular way, there's much less incentive to DSEL things up.

I'm afraid I still don't see. Could you add some comments to your
code? What about that code makes it "modular"?

> The advantages of this style are not apparent in simple examples
> where there's no reuse within the generated XML, either in the same
> document, or across documents.
>
> In other words, if the <author> tag occurs several times in the schema(s),
> in different contexts, I'm able to just reuse my add_element overload that
> takes a C++ author class, without repeating the same tags over and over in a
> declarative way.

Aren't you just repeating your procedural calls to add_element over
and over?

> Similarly, if several elements in the schema have a lot of common, I
> can use C++ inheritance to factor the common core into a base class
> and have it have its own add_element function, which would save me
> the trouble of repeating the common parts in each subclass element.

I'm sorry, I know you must be making a good point, but I'm still not
seeing it. Help... please... :)

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

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