callback not working as expected with overloaded variants of functions

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

callback not working as expected with overloaded variants of functions

sledorze
I have those functions defined for an extern (Db) :

  @:overload(function () : Cursor {})
  @:overload(function (callBack : Error -> Cursor -> Void) : Void {})
  public function collectionsInfo(collection_name : String, callBack : Error -> Cursor -> Void) : Void;

and tries to do that:

        var f1 : String -> (Error -> Cursor -> Void) -> Void = callback(db.collectionsInfo); // Works


        var f2 : (Error -> Cursor -> Void) -> Void = callback(db.collectionsInfo); // Fails

I though this could could unify with the overloaded version of the function thanks to the provided type signature..

Did I miss something or should I fill up an issue now?

Let me know..
Stephane
Reply | Threaded
Open this post in threaded view
|

Re: callback not working as expected with overloaded variants of functions

sledorze
Maybe another instance of the same problem:

Providing the same type siganture

and puttin this extension into scope (using 'using'):

  public static function eitherFunc < A, B > (f : (A -> B -> Void) -> Void) : (Either < A, B > -> Void) -> Void return
    function (cb : Either < A, B > -> Void)
      f(function (a : A, b : B)
        cb (if (a != null) Left(a) else Right(b))
      )

this doesn't works either:

        db.collectionsInfo.eitherFunc();

It says the non variant version of the method has no such field; failing to test with its variants..

So I'm pretty sad with my experiments.. :'(

Do some mighty god wanna look at fixing that unification issue?
Reply | Threaded
Open this post in threaded view
|

Re: callback not working as expected with overloaded variants of functions

Nicolas Cannasse
In reply to this post by sledorze
Le 17/10/2011 12:20, sledorze a écrit :

> I have those functions defined for an extern (Db) :
>
>    @:overload(function () : Cursor {})
>    @:overload(function (callBack : Error ->  Cursor ->  Void) : Void {})
>    public function collectionsInfo(collection_name : String, callBack : Error
> ->  Cursor ->  Void) : Void;
>
> and tries to do that:
>
>          var f1 : String ->  (Error ->  Cursor ->  Void) ->  Void =
> callback(db.collectionsInfo); // Works
>
>
>          var f2 : (Error ->  Cursor ->  Void) ->  Void =
> callback(db.collectionsInfo); // Fails

@:overload only works for immediate calls. It does not work if your
parameters types are yet unknown.

Think of it as a fallback in case a typing error occur when calling the
method (which is the actual implementation).

Nicolas

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

Re: callback not working as expected with overloaded variants of functions

sledorze
Humm.. I understand it complicates typing..
I guess this extends to any code transformation we're talking about.. (CPS, etc..), right?


On Mon, Oct 17, 2011 at 12:51 PM, Nicolas Cannasse [via Haxe] <[hidden email]> wrote:
Le 17/10/2011 12:20, sledorze a écrit :

> I have those functions defined for an extern (Db) :
>
>    @:overload(function () : Cursor {})
>    @:overload(function (callBack : Error ->  Cursor ->  Void) : Void {})
>    public function collectionsInfo(collection_name : String, callBack : Error
> ->  Cursor ->  Void) : Void;
>
> and tries to do that:
>
>          var f1 : String ->  (Error ->  Cursor ->  Void) ->  Void =
> callback(db.collectionsInfo); // Works
>
>
>          var f2 : (Error ->  Cursor ->  Void) ->  Void =
> callback(db.collectionsInfo); // Fails
@:overload only works for immediate calls. It does not work if your
parameters types are yet unknown.

Think of it as a fallback in case a typing error occur when calling the
method (which is the actual implementation).

Nicolas

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



To unsubscribe from callback not working as expected with overloaded variants of functions, click here.



--
Stéphane Le Dorze


Reply | Threaded
Open this post in threaded view
|

Re: callback not working as expected with overloaded variants of functions

Nicolas Cannasse
Le 17/10/2011 13:13, sledorze a écrit :
> Humm.. I understand it complicates typing..
> I guess this extends to any code transformation we're talking about..
> (CPS, etc..), right?

Yes @:overload only works for immediate calls when you know the
arguments types.

Nicolas

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

Re: callback not working as expected with overloaded variants of functions

sledorze
Sorry, failed to articulate my question correctly;
I understand that's the current state of affairs..
..and wanted to know if it is something that could change when those future transformations are available - or not.


On Mon, Oct 17, 2011 at 1:17 PM, Nicolas Cannasse [via Haxe] <[hidden email]> wrote:
Le 17/10/2011 13:13, sledorze a écrit :
> Humm.. I understand it complicates typing..
> I guess this extends to any code transformation we're talking about..
> (CPS, etc..), right?

Yes @:overload only works for immediate calls when you know the
arguments types.

Nicolas

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



To unsubscribe from callback not working as expected with overloaded variants of functions, click here.



--
Stéphane Le Dorze