type inference for type parameters don't seem to be implemented

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

type inference for type parameters don't seem to be implemented

Jordo Odroj
Am I doing something wrong?

If I have some class:
class Parent<T> {
    private var t: T;
    new(t: T) {
        this.t = t;
    }
}

And then inherit:
class Child extends Parent {
     function new() {
         super("HELLO!");
     }
}

Then it seems like we should infer that Child extends Parent<String>. I Couldn't get this to work. Any suggestions?
Currently I have to say "extends Parent<String>"

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: type inference for type parameters don't seem to be implemented

Nicolas Cannasse
Le 26/02/2011 08:56, Jordo Odroj a écrit :

> Am I doing something wrong?
>
> If I have some class:
> class Parent<T> {
>      private var t: T;
>      new(t: T) {
>          this.t = t;
>      }
> }
>
> And then inherit:
> class Child extends Parent {
>       function new() {
>           super("HELLO!");
>       }
> }
>
> Then it seems like we should infer that Child extends Parent<String>.

Such type inference is very hard to get right, so it's not implemented
and there's no plans for it.

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: type inference for type parameters don't seem to be implemented

Jordo Odroj
I see. I can understand why that would be extremely difficult. No worries. I consider the extra 20 seconds I spend when making a complex inherited class is worth it anyways. If you don't know your data well enough to write the type definitions, then you're screwed anyways. 

:)

On Sat, Feb 26, 2011 at 12:02 AM, Nicolas Cannasse <[hidden email]> wrote:
Le 26/02/2011 08:56, Jordo Odroj a écrit :

Am I doing something wrong?

If I have some class:
class Parent<T> {
    private var t: T;
    new(t: T) {
        this.t = t;
    }
}

And then inherit:
class Child extends Parent {
     function new() {
         super("HELLO!");
     }
}

Then it seems like we should infer that Child extends Parent<String>.

Such type inference is very hard to get right, so it's not implemented and there's no plans for it.

Nicolas

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org