Writing XML

Christopher Nicholson-Sauls ibisbasenji at gmail.com
Tue Feb 8 22:16:50 PST 2011


On 02/06/11 18:18, Tomek Sowiński wrote:
> Rainer Schuetze napisał:
> 
>> This looks nice and compact Using opDispatch to specify the tag (I guess 
>> that is what you are using to create a tag "book" by calling xml.book()) 
>> feels like misusing opDispatch, though. Does it add readability in 
>> contrast to passing the tag as a string to some function?
>>
>> How do you write a tag named "tight"? Or a tag calculated at runtime?
> 
> xml.tag("tight", attributes..., { make content });
>  
> That's the base implementation. opDispatch is just syntax sugar over it.

Might I suggest changing the sugar to have a suffix?  Ie, instead of
xml.book(...) as sugar for xml.tag("book",...) make it xml.bookTag(...)
instead (or something similar).  Very easy to check for using an if
condition, and in the event that some XML application actually has a
"tag" tag... well, xml.tagTag() might look funny, but at least it'd
work.  Could also support "_tag" as an alternate suffix for those with
such sensibilities; xml.book_tag(...).

-- Chris N-S


More information about the Digitalmars-d mailing list