Ok, so the parameter can only be an integer or a type, am I right ? Is it 
specified in the manual ?

Thanks,
Sébastien
Le vendredi 28 novembre 2014 01:50:37 UTC+1, [email protected] a écrit :
>
> The parameter to MyType{} needs to be a type, but Joker() is an instance. 
>  Just use  MyType{Joker}(4)
>
> Cheers
> Lex
>
> On Friday, November 28, 2014 9:50:08 AM UTC+10, [email protected] 
> wrote:
>>
>> Hello,
>>
>> Say I have a parametric type:
>>
>>     type MyType{T}
>>          var1
>>     end
>>
>>
>>
>> In the most of the case T is a simple integer, and there is no problem 
>> with that. However, sometimes T is an instance of an singleton type, like:
>>
>>   
>>   type Joker end
>>
>>
>> Thus I would like to instantiate
>>
>> MyType{Joker()}(4)
>>
>> but I have the following error message:
>>
>>     ERROR: type: apply_type: in MyType, expected Type{T<:Top}, got Joker
>>
>>
>>
>> Reading this message, I understand that the parameters of the types have 
>> to be define "at the top"... This seems true while 
>> MyType{MyType{4}(3)}(2)
>> throw a similar error message.
>>
>> In the documentation : 
>> http://julia.readthedocs.org/en/latest/manual/types/#man-parametric-types 
>> there is no mention of such a restriction (or I didn't find it!).
>>
>> How can I make `MyType{Joker()}(4)` work the way I want ?
>>
>> Regards,
>> Sébastien
>>
>

Reply via email to