Boost logo

Boost :

Subject: Re: [boost] Assign V2 - first impression
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2011-06-24 15:00:26


er wrote:
> If I try to imagine what the interface would look like after taking
> into account some of the suggestions that were made, this sentence:
>
> "Create data elements by mapping 1, 10, 100, 1000 by function f, and
> insert each result in cont by invoking modifier push_front."
>
> translates to
>
> (
> push_front<1>( cont ) % ( _data = f ) % ( _repeat = n )
> )( 1, 10, 100, 1000 );
>
>
> Questions :
> - is it more readable, now?
> - What if each example was preceded by its English equivalent. Is
> this a
> bit of stretch or a reasonable approach?

No, the % operator is ascii art.

I guess % means "modifier" in this context, that we are parameterizing the push front.

I don't see how what you wrote above is any more readable than this:

push_front<1>( cont ) ( _data = f ) ( _repeat = n ) ( 1, 10, 100, 1000 );

But why not pull the modifiers into push_front as optional arguments using boost param

push_front<1>( cont, _data = f, _repeat = n ) ( 1, 10, 100, 1000 );

Now it is more clear. I'd still probably need to read the documentation to understand the meaning of _repeat (is it repeat each element or repeat the sequence?) but only the first time I saw it.

The concern about needing to read the documentation to read the code is that if the documentation is a magic decoder ring without which the code is unintelligable. People should be able to guess what the code is doing and their guess should be correct, otherwise the interfaces are not intuitive.

Regards,
Luke


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