Just in case there is another solution that may work within the confines of 
your application. 

On Sunday, June 7, 2015 at 6:01:14 PM UTC-4, andrew cooke wrote:
>
>
> why do you ask?
>
> On Sunday, 7 June 2015 10:35:10 UTC-3, David Gold wrote:
>>
>> What is the application in which you intend to use such a feature?
>>
>> On Saturday, June 6, 2015 at 6:49:53 PM UTC-4, andrew cooke wrote:
>>>
>>>
>>> Is there any way to switch the "visible" type - the thing that is 
>>> dispatched on - at runtime?
>>>
>>> For example, you might think that a Union() could do this, but the 
>>> "visible" type is either always be the Union, and not either of the 
>>> subtypes, or doesn't allow the value to be changed.
>>>
>>> julia> type A{T<:Union(Void,Int)} a::T end
>>>
>>> julia> A(1)
>>> A{Int64}(1)
>>>
>>> julia> A(nothing)
>>> A{Void}(nothing)
>>>
>>> julia> A(nothing).a = 1
>>> ERROR: ...
>>>
>>> julia> A{Union(Void,Int)}(nothing).a = 1
>>> 1
>>>
>>> Not sure if those examples make things clear, but when the type of A is 
>>> explicitly A{Void} then the contents cannot be changed to an Int.  And if 
>>> the type is explicitly A{Union(...)} then the value can be changed, but the 
>>> "visible" type remains the Union and cannot be dispatched on.
>>>
>>> Thanks,
>>> Andrew
>>>
>>>
>>>
>>>

Reply via email to