|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-06-10 14:33:57
"Vesa Karvonen" <vesa_karvonen_at_[hidden]> writes:
> I agree that the comment should be removed. I think that the comment has
> probably been more relevant at some stage (CVS would probably reveal it
> if this was the case), but the context was lost during editing. That
> ''BOOST_PP_DEC(I) essentially expands to "I-1"'' is hardly an
> implementation detail.
Well, it isn't correct, either. BOOST_PP_DEC(3) doesn't expand to
"3-1"; it expands to 2
>>Is this really better than iterating over a SEQ of categories in any
>>way other than efficiency?
>
> At the time when the example was written, SEQ had not yet been invented
> and even lists were not as efficient and convenient as they are today.
> Unfortunately, the example was never updated. Today, I would generally
> advocate using a sequence (or some other data structure).
So that example should be stricken.
>> Example - Use BOOST_PP_REPEAT to avoid O(n*n) repetition.
>>
>>It's unclear to me how that example avoids O(n*n) repetition.
>
> The point is to avoid manual, source code time, repetition and replace it
> with automated, preprocessing time, repetition. The code that you will
> edit after using REPEAT will be only O(1) (and not O(n*n)).
>
> It is the same as using a high level language to avoid programming in
> machine language. Sure, the compiler translates the high level code to
> machine language (well, not exactly, but close enough), but this doesn't
> mean that (because of the translation) you would not be avoiding
> programming in machine language as you seem to suggest.
No, I'm just suggesting that it's unclear what you mean when you write
"avoid O(n*n) repetition". I took it to mean "avoid an inefficient
use of the preprocessor resulting in O(n^2) complexity".
>> Example: Use arithmetic, logical, and comparison operations when
>> necessary.
>>
>>With no commentary, and no generated code, this example is really
>>useless. I mean, of course you'd use arithmetic, logical, and
>>comparison operations "when neccessary".
>
> Looking at an old [...], there used to be a comment:
>
> "<P>The PREPROCESSOR library supports saturated arithmetic, logical
> and comparison operations on decimal integer literals in the range
> [0,BOOST_PP_LIMIT_MAG].</p>
>
> <p>Suppose that you want to generate a numbered lists with a special
> element inserted at a desired position. For example: E0, E1, S, E2.
> Consider the following example:</p>"
Putting it back would help.
> The point of the example was really just to let the reader know that the
> library does contain macros for arithmetic, logic, etc...
>
> The example is admittedly weak and only designed to use some of the
> mentioned classes of macros.
I think there should also be something that draws the distinction
between
BOOST_PP_ADD(4,7)
and
4+7
and explains why you sometimes need the former.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk