List Info

Thread: templates, macros and spaces




templates, macros and spaces
user name
2006-05-31 23:29:48
John Maddock wrote:
> David Abrahams wrote:
>> "John Maddock" <johnjohnmaddock.co.uk> writes:
>>
>>> 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.
>> In ReST they have a "breaking
non-space."  That is, if you
>> backslash-escape a space character, you get
something that can
>> separate tokens without generating any space in the
output:
>>
>>  x\ super(2)
>>
>> In quickbook maybe that should be:
>>
>>  x[]super(2)
>>
>> Although I think I might prefer:
>>
>>  x!super(2)
>>
>> An exclamation point with no whitespace on either
side is sufficiently
>> rare, I think.
> 
> That would do it, but note that we already have a
poor-man's version of this 
> using an empty comment:
> 
> x[/]super(2)

Good idea! It should definitely work. The reason why it is
not working
is unrelated, but I think I know why.

> But you still get the extra whitespace :-(

Ok, here's what I think:

My proposed syntax:

    x[super 2]

does not have this problem. You do not need to add a space
between
x and the template /super/. It is also sufficiently
unambiguous.
It does not look like a common function call so you do not
have
to resort to some naming convention, like
double-underscores.

If there are no objections, I'd like to switch to this
syntax to
templates. Applying it to macros will break existing qbk
files,
which I do not want to do. So, I'll just let them be and
get
them deprecated. That means, I'd like templates to totally
replace
macros.

So, going back to John's experiment, I'd like the final
qbk code
to be:

     [template alpha[] '''&alpha;''']
     [template super[text]
'''<superscript>'''[text]'''</superscript&
gt;''']
     [template pow[a, b]
[a]'''<superscript>'''[b]'''</superscript&
gt;''' ]

Notice [text], [a] and [b] are bracketed. They are
essentially
templates that exist only in the duration of the template
body
(that is their scope). Notice too that alpha[] is a nullary
template.

Then...

     x[super 2]
     [pow[x][2]]
     [pow[alpha][2]]

I am confident I can get this to work. Comments? Objections?

> Even this:
> 
> x'''<superscript>2</superscript>'''
> 
> has extra whitespace inserted!

Which is clearly wrong. I'll investigate some more. I think
it has to do
with tagging escaped HTML and placing them in separate line.

Regards,
-- 
Joel de Guzman
http://www.boost-cons
ulting.com
http://spirit.sf.net



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

about | contact  Other archives ( Real Estate discussion Medical topics )