Add the following logic to the C `load' function:
Before loading either the .el or .elc file, test for the condition
where the .el file is newer than the .elc file. If it is, then do
the following:
See if the `load-hook-stale-byte-compile-handlers' hook variable
is set to non-nil. When it is non-nil, run the hook variable with
`run-hook-with-args-until-success'. Each function the user has
added to that hook variable would do any logic s/he wishes,
including in my case to popup a minibuffer prompt asking what to
do. When the hook function thus called returns a 'prefer-el-file
symbol, `load' then loads the .el file and ignores the .elc
file. Likewise, when the hook function returns the
'prefer-elc-file symbol, then load the .elc file but give no
warning message and ignore the .el file. When nil is returned from
the `run-hook-with-args-until-success' function, just load the
.elc file and produce the stale file warning message as is done
today (i.e., preserve existing behavior).
That would work, but it is IMHO too much (interface, not code)
complexity for little gain. In most cases, having a .elc older than
its corresponding .el is a bug (or, let's call it, a temporary
situation), so getting a warning to remind the user about fixing it
seems much more economical.
That said, sometimes I would've liked to have a hook that runs when a
file is loaded; or the ability to defadvice Fload (you can, except
that Fload is also called from C code, for example for autoloads).