Why I'm hesitating to switch to D

KennyTM~ kennytm at gmail.com
Thu Jun 30 07:50:07 PDT 2011


On Jun 30, 11 22:31, Adam Ruppe wrote:
> KennyTM~ wrote:
>> Right. I agree this is one disadvantage in authoring the document.
>> Although, in terms of readability, this is much better than
>>
>> $(TABLE
>> $(TR
>>   $(TH Header)
>>   $(TH Header2)
>
>
> Note that textual macros can do a *lot* better than this. If we
> take advantage of recursive template expansion....
>
> ======
>
> $ cat test73.d
> /**
>          $(TABLE
>                  $(HEADERS Something,    Something Else, Something To End)
>                  $(ROW     This is it,   So is this,     And the third)
>                  $(ROW     This is it,   So is this,     And the third)
>                  $(ROW     This is it,   So is this,     And the third))
>
>          Macros:
>                  TABLE=<table>$0</table>
>
>                  TH=<th>$1</th>$(TH $+)
>                  HEADERS=<tr>$(TH $1, $+)</tr>
>
>                  TD=<td>$1</td>$(TD $+)
>                  ROW=<tr>$(TD $1, $+)</tr>
> */
>
> $ dmd -D test73.d
> $ cat test73.html
>
> <table>      <tr><th>Something</th><th>Something Else</th><th>Something To
> End</th></tr>
>                  <tr><td>    This is it</td><td>So is this</td><td>And the
> third</td></tr>
>                  <tr><td>    This is it</td><td>So is this</td><td>And the
> third</td></tr>
>                  <tr><td>    This is it</td><td>So is this</td><td>And the
> third</td></tr></table>
>
> =======
>
>
> That's fairly readable in source and generates the html needed,
> that looks pretty decent.
>
> The default ddoc macros need more work than ddoc itself IMO.

Interesting trick! Thanks. Indeed the default DDoc macros are not very 
good, e.g. having no inline code format ($(D x) in Phobos), and relying 
on the presentational aspect of HTML (e.g. DDOC_BUGS = $(RED 
BUGS:)$(BR)$0$(BR)$(BR)), etc.


More information about the Digitalmars-d mailing list