Boost logo

Boost :

Subject: Re: [boost] Assign V2 - first impression
From: er (er.ci.2020_at_[hidden])
Date: 2011-06-24 15:07:20


On 6/24/11 2:55 PM, Stewart, Robert wrote:
> er wrote:
>> On 6/24/11 2:17 PM, Stewart, Robert wrote:
>>> er wrote:
>>
>>>> Map 1, 10, 100, and 1000 by function f,
>>>> which yields f( 1 ), f( 10 ), f( 100 ), f( 1000 )
>>>> and insert each, n times, using push_front, in cont.
> [snip]
>>> IOW, something more like the following would suit me better:
>>>
>>> Insert elements in cont, using push_front(), where the
>>> values are generated by calling f() n times with 1, 10,
>>> 100, and 1000, in turn.
>>
>> Thanks for trying to get to the bottom of it. I agree that the
>> wording in English might call for Insert in the beginning. But
>> the actual sequence of events is like this:
>
> The English description, as I understood what you were proposing, is an introduction to the example code. It should be about the desired outcome, not the sequence of actions or its efficiency. It is something of a motivating statement.

Yes, you are right that the English description should focus on the
outcome. But I remain uneasy about "calling f() n times", because if f
depends on a state i, such that f() internally triggers i++, the outcome
is not the same. It turns to be harder than I anticipated to phrase it
in English without recourse to pseudo code...

>> Each of x = 1, ..., 1000 is forwarded to a data-generator, f.
>> The result of f( x ), which I call y, is forwarded to a
>> modifier which, here, executes:
>> repeat n times { cont.push_front( y ); }
>
> That's reasonable to describe what the example code actually does, but it shouldn't be the example's introduction.

Indeed.

>
>> The sequence matters, because f( x ) is computed only once,
>> which is the most efficient way.
>
> That's good to point out, but not in the example's introduction.

Right.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk