Adding extra parameter to hook function in custom module / get custom variable inside a hook from outside of that hook
You're already doing it the right way. You aren't in control of that particular hook so you can't control how it's invoked, and what parameters are passed.

Couple that with this information from the drupal_alter() docs:


  A maximum of 2 alterable arguments is supported. In case more arguments need to be passed and alterable, modules provide additional variables assigned by reference in the last $context argument:


And that means that in order to make changes to the arguments you'll need to patch the module that provides the hook. 

You might want to consider variable_get() and variable_set() if the $foo variable is likely to change at all, or DB storage if it's something major. 

But using a helper function to return that data is perfectly good practice; there are dozens of examples of the same in Drupal core itself.

Or....you could use the global keyword (emphasis because I wouldn't personally recommend it, it's not particularly good practice to pollute the global scope).

That would go something like this:

$foo = 1;
function hook_tapir_table_alter (&amp;$table, $table_id )  {
  global $foo;
  echo $foo;
}