[Issue 4277] delegate reference wrong scope var value

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 28 20:45:34 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4277


changlon <changlon at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #8 from changlon <changlon at gmail.com> 2010-06-28 20:45:28 PDT ---
IF I understood correct, the dwt.widgets.Listener design by Frank Benoit  is
danger in d1.  the source is:

------------------------------------------
module dwt.widgets.Listener;

import dwt.widgets.Event;
import tango.core.Traits;
import tango.core.Tuple;

public interface Listener {
void handleEvent (Event event);
}


/// Helper class for the dgListener template function
private class _DgListenerT(Dg,T...) : Listener {

    alias ParameterTupleOf!(Dg) DgArgs;
    static assert( is(DgArgs == Tuple!(Event,T)),
                "Delegate args not correct: delegate args:
("~DgArgs.stringof~") vs. passed args: ("~Tuple!(Event,T).stringof~")" );

    Dg dg;
    T  t;

    private this( Dg dg, T t ){
        this.dg = dg;
        static if( T.length > 0 ){
            this.t = t;
        }
    }

    void handleEvent( Event e ){
        dg(e,t);
    }
}

Listener dgListener( Dg, T... )( Dg dg, T args ){
    return new _DgListenerT!( Dg, T )( dg, args );
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list