Boost logo

Boost :

From: Itay Maman (itay_maman_at_[hidden])
Date: 2003-02-22 03:18:24


"Ronald Garcia" <garcia_at_[hidden]> wrote in message
news:Pine.GSO.4.50.0302211623450.6501-100000_at_trillian.osl.iu.edu...
>
> Hi,
>
> In reading through the variant docs, I noticed a requirement that at least
> two types must be supported by the variant. Is this meant for ease of
> library implementation, or is this a means of protecting programmers from
> themselves? :-)
>

The latter: The rationale was that a developer is better off with handling a
single value directly, rather than wrapping it inside a variant.

> It may not make sense for a human programmer to instantiate a variant
> with one value in it, but I can picture situations where a code generator
> might create a variant of only one type. Handling this as a
> special case can be tedious -- I have had related problems in the past
> generating structs of zero elements in C. Even when a human programmer is
> involved, one might prefer the clarity of a consistent implementation
> style over the performance gain of special casing. These situations might
> be worth considering.
>

I agree with you. This is all about sound "code engineering": A mechanism
may start with a single type but may need to support more and more types as
time go by. As it stands now, you will have to start with two types.

This is a good point. Thanks.

--
Itay Maman
    itay_maman@_yahoo_.com
    maman_at_il._ibm_.com
This message expresses my personal opinion.

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