Lars Gullik Bjønnes wrote:
>>> bool BranchList::remove(string const & s)
>>>  {
>>>          List::size_type const size = list.size();
>>> -        list.remove_if(bind2nd(match(), s));
>>> +        list.remove_if(bind(equal_to<string>(),
>>> +                            bind(&Branch::getBranch, _1),
>>> +                            s));
>>>          return size != list.size();
>>>  }
>>
> | Lars! Be nice to us! Add comments explaining what this stuff is
> | equivalent to. If you're not careful, your fellow developers will
> | start to view you as the evil genius who obfuscates their
> | perfectly reasonable code and then laughs at their confusion, "Mu
> | hah hah hah!"
> 
> Where is the obfuscation?
> 
> Actually I find the new version a lot clearer than the old one. Now
> you can actually see what "match" is doing: equal_to. std::equal_to
> takes to parameters, the elements to be compared, in this case:
> Branch::getBranch() and s.
> 
> So: remove the element if equal_to is true when supplied with the
> parameters Branch::getBranc() (for each element of the list) and s.

Yes, I understand that, because I have used bind a lot myself. 
However, a comment to this effect would be good too.

> | Would boost::lambda help here?
> 
> The code would probably be even clearer with boost::lambda.

Try me. I've never actually used it, so would like to see a real-world 
example

> PS. To get the more "obfuscated" stuff you should have picked the
> make_function_output_iterator stuff. Or the operator-> stuff...

I wasn't trying to start a competition on who can write the most 
obfuscated code. I was complaining that you are in danger of being 
viewed in such a light. Unfair to you and unfair to the rest of us.

-- 
Angus

Reply via email to