
Mat Marcus <mat-lists@emarcus.org> writes:
Having not used optional extensively, I don't have a strong opinion on which interface might be better, but it's been my experience that objections to the pointer interface seem to be moral positions not backed up by any sound technical argumentation. That said, moral positions count when they are connected to votes in the committee, so if there's a general consensus against the pointer interface there, the onus is on those in favor of it to produce sound argumentation in favor.
-- Dave Abrahams
Dave's "experience" of the objections to the pointer-like syntax as being "moral positions not backed up by any sound technical argumentation" would have been different had he actually been present at the discussion.
Hey, I didn't say my experience was extensive :)
Here are a few of the objections to the pointer interface that were raised in the discussion:
1) At a large company, I promoted and supported the use of optional. It was my experience that the pointer-like syntax confused a number of programmers. They were not "junior" programmers. The confusion centered around whether optional<Foo> had value semantics or pointer semantics, especially under copying.
That is a real issue.
(Ironically, when the straw vote was taken as to whether to continue pursuing optional for the standard, I voted a "strong yes", while another committee member indicated that he was presently leaning towards a no vote since "we have enough shared_ptr-like components in the library already".
Wow, that's a little scary. Was that someone who's generally on the ball, or one of those very few who sometimes vociferously object to what's being proposed on the grounds that it doesn't do the very thing it actually does?
Of course, as the proposal advances further, I expect him to study it more carefully.)
That would be nice, wouldn't it?
To be fair to Dave, perhaps his impression came from a later discussion that we had in the lobby.
Well, that was part of it, and it was the only experience I had of your point of view on the matter. However, I've heard similar objections in this list, so I wasn't basing my remarks only on our conversation. I think it's a simple question of whether the implication of reference semantics is strong and problematic enough to warrant changing. I don't know how we measure that. I wonder if your people would've been less confused had the optional<> docs contained a large Warning: This is not a pointer. It uses pointer syntax, but when an nonempty optional<T> is copied, it copies the T as well. An optional<T> object always occupies at least sizeof(T) bytes of storage. -- Dave Abrahams Boost Consulting www.boost-consulting.com