|
Threads-Devel : |
From: Anthony Williams (anthony_at_[hidden])
Date: 2008-03-13 12:20:42
Hi Frank,
Quoting Frank Mori Hess <frank.hess_at_[hidden]>:
> On Tuesday 11 March 2008 17:14 pm, Anthony Williams wrote:
>> Quoting Frank Mori Hess <frank.hess_at_[hidden]>:
>> > Also, have you considered supporting implicit conversions between
>> > future<U> and future<V> where there is an implict conversion between U
>> > and V? My libpoet library does that, and it's helpful for passing
>> > futures between active object functors that return futures and accept
>> > them as arguments.
>>
>> I haven't considered that. It seems awkward to me, as you could start
>> with a future<U>, convert to future<V>, then to future<W>, then to
>> future<X>, then to future<Y>. In each case there would be an implicit
>> conversion, but you wouldn't normally be able to convert a U to a Y
>> (too many UDCs).
>
> I'm not sure what you mean by "too many UDCs"?
When converting from type A to type B, you're only allowed one
user-defined conversion (UDC). If U has no direct conversion to Y,
then the chain U->V->W->X->Y has too many UDCs to be considered for
conversion.
>> For this to work, therefore, you'd have to wrap the
>> internal data with every conversion, otherwise some future<V>s could
>> be converted to future<W>s, but not others. How did you handle this
>> case?
>
> I'm not sure which case you're thinking of when you say some futures could be
> converted but not others?
If your future<V> really stores a U, you can't convert this to a
future<W> (since U is not convertible to W) unless you wrap the stored
U in a layer that converts to a V.
> Wrapping the internal data with every conversion
> sounds roughly like what I did. I tried to make the conversions for futures
> behave just like the values they are wrapping. So in the example you give,
> the value for the future<Y> will be created by going through all the
> conversions U to V to W to X to Y. U does not have to be directly
> convertible to Y.
OK. I understand the approach, I'm just not sure I like it --- you
started with a future<U>, and somehow you've got a future<Y> by adding
a load of intermediate layers.
Anyway, this can always be added later.
Anthony
-- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL