Big Patch

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

Big Patch

Nicolas Cannasse
Hi,

I have just commited quite a big patch on haxe SVN (r3850).

Since it change quite a lot of things in compiler algorithms, I would be
happy if some of you could test your code with this version and report
me if you have any issues.

The patch changes the way compiler internals handle local variables.
Instead of having a string name, there is now a small structure with the
variable name and an unique id.

This allow to simplify several important algorithms such as inlining,
since they don't have to track local variable shadowing anymore by
relying on the variable unique id instead.

It is also possible to rename the local variable by simply mutating its
name in the structure, instead of mapping the whole AST.

This way variable unique-name generation (for scope-based platforms such
as JS and Flash) is now postponed to the very-end of compilation.

Enjoy !

Nicolas

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

Re: Big Patch

Michael Baczynski-2
Hi,

seems compilation is broken with r3850:

File "optimizer.ml", line 127, characters 3-38:
This expression has type Type.texpr but is here used with type int
Error while running ocamlopt -c -I ../ocaml -I ../ocaml/swflib -I ../ocaml/xml-light -I
../ocaml/extc -I ../neko/libs/include/ocaml -pp camlp4o ast.ml lexer.ml typ
e/ocaml/binast.ml ../neko/libs/include/ocaml/nxml.ml genneko.ml genas3.ml genjs.ml genswf8.ml
genswf9.ml genswf.ml genphp.ml gencpp.ml interp.ml typer.ml main.ml


On 16.07.2011 18:08, Nicolas Cannasse wrote:

> Hi,
>
> I have just commited quite a big patch on haxe SVN (r3850).
>
> Since it change quite a lot of things in compiler algorithms, I would be happy if some of you could
> test your code with this version and report me if you have any issues.
>
> The patch changes the way compiler internals handle local variables. Instead of having a string
> name, there is now a small structure with the variable name and an unique id.
>
> This allow to simplify several important algorithms such as inlining, since they don't have to track
> local variable shadowing anymore by relying on the variable unique id instead.
>
> It is also possible to rename the local variable by simply mutating its name in the structure,
> instead of mapping the whole AST.
>
> This way variable unique-name generation (for scope-based platforms such as JS and Flash) is now
> postponed to the very-end of compilation.
>
> Enjoy !
>
> Nicolas
>


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

Re: Big Patch

sledorze
In reply to this post by Nicolas Cannasse
May I kiss you!

Stephane

Not sent by drunk friends from the IPad I dunnot own..
Reply | Threaded
Open this post in threaded view
|

Re: Big Patch

sledorze
In reply to this post by Nicolas Cannasse
Does this means inlining will be able to get back to what's described in the wiki?
Or better, remove some inlining restrictions (line not able to inline function containing a closure)? :)
Thanks!
Stephane

Reply | Threaded
Open this post in threaded view
|

Re: Big Patch

Nicolas Cannasse
In reply to this post by Michael Baczynski-2
Le 16/07/2011 19:22, Michael Baczynski a écrit :

> Hi,
>
> seems compilation is broken with r3850:
>
> File "optimizer.ml", line 127, characters 3-38:
> This expression has type Type.texpr but is here used with type int
> Error while running ocamlopt -c -I ../ocaml -I ../ocaml/swflib -I
> ../ocaml/xml-light -I ../ocaml/extc -I ../neko/libs/include/ocaml -pp
> camlp4o ast.ml lexer.ml typ
> e/ocaml/binast.ml ../neko/libs/include/ocaml/nxml.ml genneko.ml
> genas3.ml genjs.ml genswf8.ml genswf9.ml genswf.ml genphp.ml gencpp.ml
> interp.ml typer.ml main.ml

Seems like a small incompatibility bewteen ocaml versions. I've commited
an update, and yes I'm expecting your bug reports :)

Best,
Nicolas

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

Re: Big Patch

Nicolas Cannasse
In reply to this post by sledorze
Le 16/07/2011 19:53, sledorze a écrit :
> Does this means inlining will be able to get back to what's described in the
> wiki?

For the JS target, the following restrictions still apply :
- if the inlined function contain a "var"
- or if one parameter is used several times in the function
the function will not be inlined.

This is because the JS generator still produce underoptimized code when
values blocks contain var declarations.

> Or better, remove some inlining restrictions (line not able to inline
> function containing a closure)? :)

Yes, this should be easily doable now.

Nicolas

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

Re: Big Patch

Michael Baczynski-2
In reply to this post by Nicolas Cannasse
I get lots of "unbound variable x" errors, but only when using haxe.rtti.Generic:
Just reported it here: http://code.google.com/p/haxe/issues/detail?id=440

best,
michael

On 16.07.2011 20:50, Nicolas Cannasse wrote:

> Le 16/07/2011 19:22, Michael Baczynski a écrit :
>> Hi,
>>
>> seems compilation is broken with r3850:
>>
>> File "optimizer.ml", line 127, characters 3-38:
>> This expression has type Type.texpr but is here used with type int
>> Error while running ocamlopt -c -I ../ocaml -I ../ocaml/swflib -I
>> ../ocaml/xml-light -I ../ocaml/extc -I ../neko/libs/include/ocaml -pp
>> camlp4o ast.ml lexer.ml typ
>> e/ocaml/binast.ml ../neko/libs/include/ocaml/nxml.ml genneko.ml
>> genas3.ml genjs.ml genswf8.ml genswf9.ml genswf.ml genphp.ml gencpp.ml
>> interp.ml typer.ml main.ml
>
> Seems like a small incompatibility bewteen ocaml versions. I've commited an update, and yes I'm
> expecting your bug reports :)
>
> Best,
> Nicolas
>


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

Re: Big Patch

Nicolas Cannasse
Le 16/07/2011 22:11, Michael Baczynski a écrit :
> I get lots of "unbound variable x" errors, but only when using
> haxe.rtti.Generic:
> Just reported it here: http://code.google.com/p/haxe/issues/detail?id=440

That was actually quite an easy fix, please update and try again ;)

Best,
Nicolas

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

Re: Big Patch

John Plsek
damn ... windows builds broken again :(

On 17 July 2011 20:32, Nicolas Cannasse <[hidden email]> wrote:
Le 16/07/2011 22:11, Michael Baczynski a écrit :

I get lots of "unbound variable x" errors, but only when using
haxe.rtti.Generic:
Just reported it here: http://code.google.com/p/haxe/issues/detail?id=440

That was actually quite an easy fix, please update and try again ;)


Best,
Nicolas

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


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

Re: Big Patch

Baluta Cristian
3852 works fine for me for the largest project i have, flash.


On Sun, Jul 17, 2011 at 2:07 PM, John Plsek <[hidden email]> wrote:
damn ... windows builds broken again :(


On 17 July 2011 20:32, Nicolas Cannasse <[hidden email]> wrote:
Le 16/07/2011 22:11, Michael Baczynski a écrit :

I get lots of "unbound variable x" errors, but only when using
haxe.rtti.Generic:
Just reported it here: http://code.google.com/p/haxe/issues/detail?id=440

That was actually quite an easy fix, please update and try again ;)


Best,
Nicolas

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


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



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

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

Re: Big Patch

Michael Baczynski-2
In reply to this post by Nicolas Cannasse
thanks, one problem remains: http://code.google.com/p/haxe/issues/detail?id=441
enjoy :)
otherwise 99% of my unit tests pass

On 17.07.2011 12:32, Nicolas Cannasse wrote:

> Le 16/07/2011 22:11, Michael Baczynski a écrit :
>> I get lots of "unbound variable x" errors, but only when using
>> haxe.rtti.Generic:
>> Just reported it here: http://code.google.com/p/haxe/issues/detail?id=440
>
> That was actually quite an easy fix, please update and try again ;)
>
> Best,
> Nicolas
>


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

Re: Big Patch

Nicolas Cannasse
Le 17/07/2011 15:01, Michael Baczynski a écrit :
> thanks, one problem remains:
> http://code.google.com/p/haxe/issues/detail?id=441

Fixed ;)

Nicolas

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

Re: Big Patch

Michael Baczynski-2
everything is working perfectly fine again:
OK 592 tests, 0 failed, 592 success :)

On 18.07.2011 10:34, Nicolas Cannasse wrote:
> Le 17/07/2011 15:01, Michael Baczynski a écrit :
>> thanks, one problem remains:
>> http://code.google.com/p/haxe/issues/detail?id=441
>
> Fixed ;)
>
> Nicolas
>


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

Re: Caller, callee or creator..

jlm@justinfront.net
In reply to this post by Nicolas Cannasse
I was just wondering about Big Patch and if it is leading in a  
direction I am interested in... well actually was sort of hoping it  
may help with callee and caller, but probably not, but maybe it's  
possible already without platform specific magic... I want to be able  
to ask an instance if it is an instance variable of an instance well  
more specifically what it is an instance variable of, I think this  
could be very useful for signals etc... an example of what I would  
like to be able to do lets assume there is a new 'creator' method on  
Std or similar that allowed me to do some scoping tricks, surely an  
instance should have some idea of where it is created?

<wishful code>
using Std;
class Person
{
         var name: String;
        var child: Person;
         function creator(): Person
         {
             return this.creator( );
         }
         function new( nom: String )
         {
            name = nom;
         }
}

fred = new Person('fred');
tom = new Person('tom');
fred.child = tom;
trace( tom.creator().name ) ;
</wishful code>

I don't know the OOP implications in terms of private etc... but seems  
it could be useful, but maybe my example/suggested wishful code would  
not be suitable, any thoughts, any way this could be implemented or  
maybe already is possible and not too heavy?

Cheers

;j




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

Re: Caller, callee or creator..

clemos
Hi

I'm not sure I get your example completely, but I think you can do
this with getter / setter (untested) :

var child ( setChild, default ) : Person;
var creator : Person;

public function setChild( p : Person ){
  this.child = p;
  p.creator = this;
}

Then:

fred.child = tom;
trace( tom.creator.name ); // "Fred"

No ?

Cheers,
Clément

On Mon, Jul 18, 2011 at 3:26 PM, [hidden email]
<[hidden email]> wrote:

> I was just wondering about Big Patch and if it is leading in a direction I
> am interested in... well actually was sort of hoping it may help with callee
> and caller, but probably not, but maybe it's possible already without
> platform specific magic... I want to be able to ask an instance if it is an
> instance variable of an instance well more specifically what it is an
> instance variable of, I think this could be very useful for signals etc...
> an example of what I would like to be able to do lets assume there is a new
> 'creator' method on Std or similar that allowed me to do some scoping
> tricks, surely an instance should have some idea of where it is created?
>
> <wishful code>
> using Std;
> class Person
> {
>        var name: String;
>        var child: Person;
>        function creator(): Person
>        {
>            return this.creator( );
>        }
>        function new( nom: String )
>        {
>           name = nom;
>        }
> }
>
> fred = new Person('fred');
> tom = new Person('tom');
> fred.child = tom;
> trace( tom.creator().name ) ;
> </wishful code>
>
> I don't know the OOP implications in terms of private etc... but seems it
> could be useful, but maybe my example/suggested wishful code would not be
> suitable, any thoughts, any way this could be implemented or maybe already
> is possible and not too heavy?
>
> Cheers
>
> ;j
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

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

Re: Caller, callee or creator..

jlm@justinfront.net
Clément

Thanks for the idea, but... Yep but that's not quite what I was thinking about ( I think? ), sorry it may seem like I was posting on a slight tangent to my requirement but I am thinking more specifically about events in javascript target but tried to keep the question generic but maybe it's better to go specific. Sorry again if my question was misleading, for instance an approaches below is simple and light, but rather ugly, but can replace event dispatcher inheritance structures and complex signals libraries so it can be a good solution ( not checked it works ).

var scope = this;
var loader = new MyLoader( callback( function()
{
   scope.loaded( loader.loadedContent, 1 );
}
, 1 )
);
loader.load( urlContent );

but obviously you sometimes want to add and remove listeners so other structures are needed, and also I find local functions like this rather dirty.  Really I am wondering about trying to keep the callback method sparse of parameter clutter as experience suggest that many times the event initiator or event info is not needed, also I prefer to avoid custom events as they assume what the listening wants to know, which I think can easily lead to more tightly coupled code, rather I prefer for the listening to ask for what it needs when it receives the event... maybe that is like an extra function call... but often you don't need any info off the sender so you can also save and can keep stuff ultra clean simple and not create new events and call functions directly or off a listener.  My original question I guess was only half formed...really I was thinking about somehow having two parents, or dual scope, mixins etc...were mentioned on irc, and have been thinking about 'using'... but no good solutions have yet come to mind maybe magic is not always a good idea.  Anyway for the moment I have an ultra simple Signal like structure which works well I just wanted to somehow add dual parent aspect to it without adding callback function parameter clutter... probably an unrealistic thought.  I don't know if arrays in javascript are ideal, I could use more complex structures and maybe only one array but wanted to keep it as simple and light but usable as possible then I can maybe modify the insides later for optimal platform performance especially if the inside uses simple standard structures as a starting point... suggestions for optimization?

example...

//class with signal / event

class MyButton
{
    public var pressed: DispatchTo;

    function new(...)
    {
       pressed = new DispatchTo();  
       ... button stuff what ever 
    }

    function onPressed()
    {
        pressed.dispatch();
    }
}

// listening class

var myButton =  MyButton;

function setupButton()
{
myButton = new MyButton(...);
        // will listen to button twice
        myButton.pressed.add( callback( buttonPress, 'a button' ), 2 );
}

function buttonPress( msg: String )
{
        trace( myButton );
        trace( msg );
}

// DispatchTo class

package zpartan ;
/**
* Copyright (c) July 2011, Justin L Mills
*   @author JLM at justinfront dot net
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of the Justin L Mills nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Justin L Mills  ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Justin L Mills  BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*

*/

class DispatchTo
{
    
    private var func:                           Array<Void -> Void> ;
    private var times:                          Array<Int> ;
    public var length( get_length, null ):      Int ;
    
    private function get_length(): Int
    {
        
        return func.length;
        
    }
    
    
    public function new()
    {
        
        func    = new Array() ;
        times   = new Array() ;
        
    }
    
    
    public function add( f_: Void -> Void, ?once: Bool, ?amount: Int )
    {
        
        func.push( f_ ) ;
        
        if( once != null )
        {
            
            if( true )
            {
                
                times.push( 1 ) ;
                
            }
            else
            {
                
                times.push( -1 ) ;
                
            }
            
        }
        else if( amount != null )
        {
            
            times.push( amount ) ;
            
        }
        else
        {
            
            times.push( -1 ) ;
            
        }
        
    }
    
    
    public function remove( f_: Void -> Void )
    {
        
        for( i in 0...func.length )
        {
            
            if( func[ i ] == f_ )
            {
                
                func.splice( i, 1 ) ;
                times.splice( i, 1 ) ;
                
            }
            
        }
        
    }
    
    
    public function dispatch()
    {
        
        var count: Int ;
        
        for( i in 0...func.length )
        {
            
            func[ i ]() ;
            count       = times[ i ] ;
            
            if( count == -1 )
            {
                
                // don't remove if -1 as implies infinite Signal use untill removed.
                
            }
            else
            {
                
                count--;
                times[ i ]  = count ;
                
                if( count == 0 )
                {
                
                    func.splice( i, 1 ) ;
                    times.splice( i, 1 ) ;
                
                }
                
            }
            
        }
        
    }
    
}


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

Re: Caller, callee or creator..

jlm@justinfront.net
I guess my question was about how to get myButton into the buttonPress function without passing it as a parameter or having it as a instance variable, in as1 you could probably have 'this' keyword scoping differently effectively giving you two parents, or you could hack a parameter onto the function itself so there were a few magic solutions.  Ok maybe not ideal solutions, but also caller and callee in flash were also interesting... so I was just thinking about approaches, I guess really buttonPress does not need to be put in the listening class but somewhere else where you can set two parents... as I said the original question was only half thought out so just fishing for alternate approaches that are outside my current box.


On 19 Jul 2011, at 16:03, [hidden email] wrote:

Clément

Thanks for the idea, but... Yep but that's not quite what I was thinking about ( I think? ), sorry it may seem like I was posting on a slight tangent to my requirement but I am thinking more specifically about events in javascript target but tried to keep the question generic but maybe it's better to go specific. Sorry again if my question was misleading, for instance an approaches below is simple and light, but rather ugly, but can replace event dispatcher inheritance structures and complex signals libraries so it can be a good solution ( not checked it works ).

var scope = this;
var loader = new MyLoader( callback( function()
{
   scope.loaded( loader.loadedContent, 1 );
}
, 1 )
);
loader.load( urlContent );

but obviously you sometimes want to add and remove listeners so other structures are needed, and also I find local functions like this rather dirty.  Really I am wondering about trying to keep the callback method sparse of parameter clutter as experience suggest that many times the event initiator or event info is not needed, also I prefer to avoid custom events as they assume what the listening wants to know, which I think can easily lead to more tightly coupled code, rather I prefer for the listening to ask for what it needs when it receives the event... maybe that is like an extra function call... but often you don't need any info off the sender so you can also save and can keep stuff ultra clean simple and not create new events and call functions directly or off a listener.  My original question I guess was only half formed...really I was thinking about somehow having two parents, or dual scope, mixins etc...were mentioned on irc, and have been thinking about 'using'... but no good solutions have yet come to mind maybe magic is not always a good idea.  Anyway for the moment I have an ultra simple Signal like structure which works well I just wanted to somehow add dual parent aspect to it without adding callback function parameter clutter... probably an unrealistic thought.  I don't know if arrays in javascript are ideal, I could use more complex structures and maybe only one array but wanted to keep it as simple and light but usable as possible then I can maybe modify the insides later for optimal platform performance especially if the inside uses simple standard structures as a starting point... suggestions for optimization?

example...

//class with signal / event

class MyButton
{
    public var pressed: DispatchTo;

    function new(...)
    {
       pressed = new DispatchTo();  
       ... button stuff what ever 
    }

    function onPressed()
    {
        pressed.dispatch();
    }
}

// listening class

var myButton =  MyButton;

function setupButton()
{
myButton = new MyButton(...);
        // will listen to button twice
        myButton.pressed.add( callback( buttonPress, 'a button' ), 2 );
}

function buttonPress( msg: String )
{
        trace( myButton );
        trace( msg );
}

// DispatchTo class

package zpartan ;
/**
* Copyright (c) July 2011, Justin L Mills
*   @author JLM at justinfront dot net
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of the Justin L Mills nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Justin L Mills  ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Justin L Mills  BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*

*/

class DispatchTo
{
    
    private var func:                           Array<Void -> Void> ;
    private var times:                          Array<Int> ;
    public var length( get_length, null ):      Int ;
    
    private function get_length(): Int
    {
        
        return func.length;
        
    }
    
    
    public function new()
    {
        
        func    = new Array() ;
        times   = new Array() ;
        
    }
    
    
    public function add( f_: Void -> Void, ?once: Bool, ?amount: Int )
    {
        
        func.push( f_ ) ;
        
        if( once != null )
        {
            
            if( true )
            {
                
                times.push( 1 ) ;
                
            }
            else
            {
                
                times.push( -1 ) ;
                
            }
            
        }
        else if( amount != null )
        {
            
            times.push( amount ) ;
            
        }
        else
        {
            
            times.push( -1 ) ;
            
        }
        
    }
    
    
    public function remove( f_: Void -> Void )
    {
        
        for( i in 0...func.length )
        {
            
            if( func[ i ] == f_ )
            {
                
                func.splice( i, 1 ) ;
                times.splice( i, 1 ) ;
                
            }
            
        }
        
    }
    
    
    public function dispatch()
    {
        
        var count: Int ;
        
        for( i in 0...func.length )
        {
            
            func[ i ]() ;
            count       = times[ i ] ;
            
            if( count == -1 )
            {
                
                // don't remove if -1 as implies infinite Signal use untill removed.
                
            }
            else
            {
                
                count--;
                times[ i ]  = count ;
                
                if( count == 0 )
                {
                
                    func.splice( i, 1 ) ;
                    times.splice( i, 1 ) ;
                
                }
                
            }
            
        }
        
    }
    
}

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


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

Re: Caller, callee or creator..

Yanis Benson
In reply to this post by jlm@justinfront.net

Why don't you just dispatch the button object like pressed.dispatch(this)? Or you can use a signal which will autodispatch it for you.

Also, in my half finished minimal GUI library I used to have tagged elements, which dispatched it's tag (which could be element itself)  but removed this feature later and leaved for some elements only, since only a small amount of elements actually needed this - mostly menu items, list items and radiobuttons. I mean, there isn't any point in dispatching any tag for single button, because 1 function per button is much clearer than one function which handles presses of many buttons with switch statement.

Anyhow... I doubt the behaviour you desire is possible without things like flash's EventDispatcher.

On 19 Jul 2011 19:26, "[hidden email]" <[hidden email]> wrote:

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