Re: init.e - standard library candidate
- Posted by ghaberek (admin) Mar 11, 2013
- 1482 views
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