Drupal 7 understanding theme registry

Theme registry is built and cached by the drupal core as part of booting process. The function "_theme_build_registry" (theme.inc) builds the theme registry. Each and every implemented theming hook will have a corresponding entry inside the theme registry. Basically each entry indicates  the process that takes place on invoking  the theming hook to which the entry belongs.  For the default bartik theme an entry inside theme registry for the theme hook "menu_link" looks like some thing as shown bellow.


$ThemeRegistry["menu_link"] = Array
(
    [render element] => element
    [type] => module
    [theme path] => modules/system
    [function] => theme_menu_link
    [pattern] => menu_link__
)

Let's say you have a link  in the form of a renderable array as shown bellow.

$link_item = array('#theme' => "menu_link",
                             '#title' => "HOME",
                             '#href' => "<front>",
                             '#below' => array(),
                             '#localized_options' => array(),
                             '#attributes' => array('class' => array('first', 'collapsed')));

$html = render($link_item);

When you render this array using the function "render"  the returned HTML looks as shown bellow. The drupal core figures out the corresponding theme function ( "theme_menu_link") that needs to be invoked by processing the theme registry. As you can see the theme registry entry shown above has a key "function" with the value "theme_menu_link" which is what finally gets invoked to return the html for the given "link_item" shown above whose key "#theme" is set to "menu_link". You can find the implementation for the function "theme_menu_link" inside "includes/menu.inc"

<li class="first collapsed"><a href="/tutorsgroundin/" class="active">HOME</a></li>