From: Augustus Saunders (infinite_8_monkey_at_[hidden])
Date: 2002-12-13 16:36:10
Fernando Cacciola wrote:
>And pointers have historically been used to deal with optional
>objects precisely because they model this concept.
I think this is important, and so I want to dwell on it for a moment.
For many years, if a programmer needed optional functionality, she
used a pointer. There are a large number of existing libraries and
APIs that use pointers to convey exactly this notion. A pointer is
essentially a defacto standard for this usage.
Consider one more time, why do iterators look like pointers? I
wouldn't be surprised if a similar discussion took place back in the
A: "I've got it! Make iterators look like pointers!"
B: "Hmm... That might confuse people. They aren't really pointers."
A: "You're right, some operators won't work on iterators."
C: "On the other hand, it would be convenient."
A: "Exactly! "
A,B,C: (thinks real hard)
C: "Also, if we make iterators look like pointers, then we can write
generic code that takes either. That way, we can interface to legacy
systems with generic code."
Eventually, they come up with concepts, which at the time I'm sure
was a radical idea. If there weren't already a large number of
libraries that use this idiom, then generic code wouldn't really
Yes, this generic code is hypothetical right now. Since the
OptionalValue concept has not been defined, nobody has tried to use
it. If we do define it and release it into the wild, will it lead to
better libraries? Consider your OS of choice's system APIs. How
many functions take or return pointers for this purpose?
Please do not dismiss the pointer interface until you have considered
this. And remember that if you push hard enough, you will discover
that smart pointers and iterators aren't really pointers. The
equivalence doesn't need to be absolute; just *useful* and *safe*.
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk