Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2005-10-14 19:14:13


David Abrahams wrote:
> Joel de Guzman <joel_at_[hidden]> writes:
>
>
>>>Rebinding semantics are there _precisely_ and _only_ to solve a problem
>>>posed by nullability.
>>
>>Sorry, I don't buy that.
>
>
> Why not?

I think this is again an artifact of the confusion between the
dual interfaces that optional provides. optional has an identity
crisis of being a pointer (as the author's original model) and
a variant<T, nil> (which I suggested later on). The rebinding
behavior that Fernando rationalized was long and winding and
confusing. I don't recall anymore his exact rationale. All I
know is that when you have to explain your design using so much
wordings, then something is wrong, and I don't buy the gobbledegook.

There *is* an alternative design which is a lot simpler and I've
been saying that again and again: do as the structs do. It is
easier to visualize and understand and ultimately to explain.
A more complex design and behavior will surely lead to more
gotchas. Keep it as simple as possible. variant<T&, nil> does
the right thing. I don't understand why optional can't. Perhaps
it's because of the dual pointer interface. But, like Mat Marcus,
I also don't buy the pointer model: "Pointers can be null or
dereference-able, Optionals can be null or dereferenceable,
therefore Optionals are models of Pointers". It seems that
Fernando's rationale follows along the lines "Pointers can be
null or dereference-able, Optionals can be null or dereferenceable,
Pointers can be rebound, therefore Optionals should be rebound-able."
Sorry, that does not work for me.

Regards,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

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