[haXe] function name<T>():Void;
Marcus Bergstrom
marcus at quickform.net
Mon Jan 22 18:27:14 CET 2007
Thanks for the help guys!
Regards,
Marcus
On Jan 22, 2007, at 6:21 PM, Bent Rasmussen wrote:
> Hello Marcus,
>
> It means that you don't have to stuff all these type parameters
> into the class parameter set. That is handy and it also means that
> you don't actually need to supply the T type value - it is
> inferred. Also, you can't just say
>
> static function getSuperClass(c : Class) : Class<Dynamic>
>
> Since class is parametric. So that that type needs to come from
> somewhere.
>
> I suppose an alternative syntax could be
>
> static function getSuperClass(c : Class<?T>) : Class<Dynamic>
>
> Best regards
> Bent
>
> ----- Original Message -----
> From: Marcus Bergstrom
> To: The haXe compiler list
> Sent: Monday, January 22, 2007 6:00 PM
> Subject: Re: [haXe] function name<T>():Void;
>
> Thanks, one more thingy...
>
> What about this one then? (which doesn't restrict the return)
> static function getSuperClass<T>(c : Class<T>) : Class<Dynamic>
>
> Marcus.
>
>
>
> On Jan 22, 2007, at 5:49 PM, Nicolas Cannasse wrote:
>
>>>
>>> You need to explain something to me. I understand Class parameters
>>> (class Array<T>) and stuff, but I am not quite clear on how it
>>> works for
>>> methods. If we take the Type class as an example, it has no Class
>>> parameters, but you can find several of these:
>>>
>>> static function createInstance<T>(cl : Class<T>, args :
>>> Array<Dynamic>) : T
>>>
>>> What does the "T" in createInstance<T> actually do.
>>> What is the difference between that and class parameters.
>>> Can someone please clarify this?
>>
>> It means that the function works for every T, but that the return
>> type
>> is bounded to the argument type. This is a more strictly typed form
>> compared to :
>>
>> createInstance(cl : Class<Dynamic>, args : Array<Dynamic>) : Dynamic
>>
>> Since in the later case, both "Dynamic" are independant.
>>
>> Nicolas
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
> --
> haXe - an open source web programming language
> http://haxe.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20070122/aa56c64c/attachment-0001.htm
More information about the Haxe
mailing list