« Return to Thread: templates, macros and spaces

templates, macros and spaces

by John Maddock :: Rate this Message:

Reply to Author | View in Thread

I've been experimenting with templates and macros over lunch (well what else
does a guy do?) and it's not really working as required just yet, given:

[def __alpha '''α''']
[template super(text) '''<superscript>'''text'''</superscript>''' ]
[template pow(a, b) a'''<superscript>'''b'''</superscript>''' ]

Then:

x super(2)

Puts a space between the x and the superscript-2

x[/ ]super(2)

So does this.

pow(x, 2)

And this :-(

pow(__alpha, 2)

Macro alpha expands OK, but that space is still there...

'''x<superscript>2</superscript>'''

Is obviously OK, but:

[template pow(a, b) '''a<superscript>b</superscript>''' ]

pow(x,2)

prints a^b not x^2 :-(

It's not just super/sub scripts either: try to define a macro or template to
expand out unit's of epsilon and the space gets even more obvious, there's
no way at present to write out 2eps using the right symbol for "eps" except
by doing the whole thing in XML.  Since the digit obviously varies from
usage to usage, that's not nice!  Try and write out an equation
"2-alpha-beta-squared" and you'd pretty rapidly give up, before it gets any
more complex.

Some of this appears to be due to XML escapes always being pretty-printed on
a new line, so

pow(x, 2) comes out as:

x
<superscript>
2
</superscript>

Which is where at least some of the spaces come from.

So.... I'm hoping that this can be solved by changing the pretty-printing
code, but I have suspicions that the problems may run deeper.

Hoping to be proved wrong,
John.



_______________________________________________
Boost-docs mailing list
Boost-docs@...
Unsubscribe and other administrative requests: https://lists.sourceforge.net/lists/listinfo/boost-docs

 « Return to Thread: templates, macros and spaces