state = 
{
  ...
};

>> ()
{
  msg_queue = create_queue ();

  frame, client = create_window (&frame_desc),
  {
    ...
  };

  msg_in (msg_queue, (pstruct -w reply, p_msg message) { 
                                                         dispatch (reply, &state, message);
                                                       }),
  {
    state _ = .;
  };
}
/
{
  free (&msg_queue);
}

window_proc (pstruct -w reply, p_state -&w _, p_msg _)
{
  select (msg->message)
  {
    case WM_CHAR:
      ...
    return;

    case WM_PAINT:
      ...
    return;
  }
  else
  {
    ;
  }
}

wm_char window_proc (p_state -&w _, p_msg _, ushort key)
{
  ...
}