'This' type

Marek Kozieł develop4lasu at gmail.com
Tue Mar 3 14:05:26 PST 2009


2009/3/3 Adrian Kuhn <akuhn at gmx.ch>

> On Mar 3, 2009, at 21:17 , Marek Kozieł wrote:
>
>  ALTERNATIVES:
>> Rewriting each method's signature on every class / interface.
>>
>
> Using self-bound generics, such as
>
> abstract class A<Self extends A<Self>> {
>        abstract Self self();
> }
>
> class B extends A<B> {
>        B self();
> }
>
> class C extends A<C> {
>        C self();
> }
>
> This is used in java.lang.Enum for example.
>
> See also http://www.artima.com/forums/flat.jsp?forum=106&thread=136394
>
> --AA


Thanks for good sample.

Although 'This' could bring relation for generics, or maybe we should think
about possibility of defining relations for generics.

-- 
Pozdrowionka. / Regards.
Lasu aka Marek Kozieł

http://lasu2string.blogspot.com/



More information about the coin-dev mailing list