Hello,

I am currently writing a little DSL for gui framework (Ruiby, for gtk).
As my DSL become more and more complex, I have some design issue.


For declaring a drawing area, with event handler, I use

canvas(w,h,{
  mouse_down: proc { |w,e|  },
  mouse_up: proc { |w,e|  },
  mouse_move: proc { |w,e|  },
  expose: proc { |w,gc|  }
})

But the list of handler becoming bigger, I wonder if this form should be
better :
canvas w,h  do
  on_mouse_up do |e|
    
  end
  on_mouse_down do |e|
     
  end
  
end

The issue is that in this form,  user can put other commands
than on_xxx in the block.
So if it put, by example, a button, I cant control what will append:
canvas w,h  do
  on_mouse_up do |e|
    
  end
  button hello do alert(coucou) end
end

so the framework will become hard to use : very common mistake will
produce exotic bug.

So here my question:
Implementing object composition by cascade of closures, how to control
the syntax of the composition?