hook(redirected from giving the hook)
Also found in: Dictionary, Thesaurus, Medical, Financial.
in machine building, a part of load-lifting machines that suspends loads or lifting attachments on the cables or chains of hoisting mechanisms (load hook); a part of transport machines that transmits tractive forces (coupling hook, draw hook), as between a tractor and trailer. Hooks are made as single hooks or double (sister) hooks. Load hooks made of cast or unit-forged steel have load-lifting capacities of up to 75 tons; laminated load hooks made of drop-forged steel plates have load-lifting capaci-ties of more than 75 tons. Coupling hooks are usually forged or cast single hooks. The main characteristics of hooks are standardized.
For example, a simple program that prints numbers might always print them in base 10, but a more flexible version would let a variable determine what base to use; setting the variable to 5 would make the program print numbers in base 5. The variable is a simple hook. An even more flexible program might examine the variable and treat a value of 16 or less as the base to use, but treat any other number as the address of a user-supplied routine for printing a number. This is a hairy but powerful hook; one can then write a routine to print numbers as Roman numerals, say, or as Hebrew characters, and plug it into the program through the hook.
Often the difference between a good program and a superb one is that the latter has useful hooks in judiciously chosen places. Both may do the original job about equally well, but the one with the hooks is much more flexible for future expansion of capabilities.
Emacs, for example, is *all* hooks.
The term "user exit" is synonymous but much more formal and less hackish.