Boost logo

Boost :

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


On 6/24/11 3:00 PM, Simonson, Lucanus J wrote:
> 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.

Almost, so bear with me.

operator% is used for passing an option, either
- a data-generator, with syntax _data = f
- a modifier, such as _push_front, ( _repeat = n ), whatever there is or
want to create.

>
> 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 );

This invokes operator() over options and arguments. There is a SFINAE
way to do it, but it thought it would be confusing. Currently, V2 uses
- operator% for options (changes the semantics)
- operator() for arguments
- operator| piping.

>
> 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.

Indeed, it's very clear. And it's quite easy to do, in fact, and not
very costly. Thanks.

>
> 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.

Stated like this I agree.

>
> Regards,
> Luke
> _______________________________________________
> Unsubscribe& other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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