Re: init.e - standard library candidate

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...
export procedure register( sequence name, integer rid = routine_id("init") ) 
	map:put( init_routines, name, rid ) 
end procedure 

You've inadvertently solved a quandary that has been plaguing me for years: How do I pass only the name of a routine to an event handler, instead of embedding routine_id() in the function call? I had no idea that initializer values were called inline, which is what seems to make this magic work.

Quite simply...

public procedure SetHandler( atom this, atom id, atom event, sequence handler, integer rid = routine_id(handler) ) 
 
    if length(handler) > 0 and rid = -1 then 
        crash( "Routine %d not found!\n", {handler} ) 
    end if 
 
    -- store handler... 
 
end procedure 
 
-- later... 
 
SetHandler( frame, wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, "MyFrame:OnClick" ) 

Am I wrong, or should this work as I expect?

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu