Boost logo

Boost :

Subject: [boost] [assign v2] thoughts
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2011-07-08 22:13:01

Hi Erwann, all,

I had a thought about this library which I wasn't able to articulate during the review, and I don't think anyone else raised it.

I think this library would be a useful utility if it had the right syntax, but I found issue especially with the use of operator| which is IMO not consistent with the way Boost.Range uses it.

I would expect the pipe operator to just stream data and not affect the object on the LHS. I know everything is relative and in some EDSLs this might be appropriate, but it's a strain for me to think of pipe as anything other than unidirectional data flow.

The syntax that you have now

cal | do_csv_put<2>("jan", 31, "feb", 28, "mar", 31)

looks kind of like Smalltalk or Objective C to me, like you are trying to send some arbitrary message to the container on the LHS.

Did you consider keeping the overloaded operator+= from Assign v1, or another assignment operator that always modifies the LHS?

cal += values<2>("jan", 31, "feb", 28, "mar", 31)

is much clearer to me. And the assignment operators are expected to return a reference to the LHS.

Yes, there is an ambiguity with other libraries which have meant += to mean "add to each element" but with the rare exception of containers containing elements of their own type, this should always be resolvable. If this is unacceptable, I think operator|=, meaning union-assign, also makes some sense.

Or am I missing something?

I always thought of Assign v1 as "the funny operator, library" and on at least one occasion didn't use it because I knew I'd have to explain what it's doing to my colleagues.

So Assign v2 looks very powerful and useful to me, but in order to become a workhorse for everyone, it has to have the most blunt obvious syntax so that no one has to guess or explain anything.


Boost list run by bdawes at, gregod at, cpdaniel at, john at