7.7 Function Overriding

Function overriding (also called function hiding) occurs when multiple function definitions share the same function name, but only one of those function definitions is visible at any point in the program due to the presence of scope holes. For instance:

A set of seven code lines demonstrating function overriding.
Description
Continuation of the code demonstrating function overriding, consisting of three lines.
Description

Here, the call to function f on line 10 binds to the outermost definition of f (starting on line 3) because the innermost definition of f (line 5) is not visible on line 10—it is defined in a nested block. The call to function f on line 7 binds to the innermost definition of f (line 5) because on line 7 where f is called, the innermost definition of f (line 5) shadows the outermost definition of f. In other words, the outermost definition of f is not visible on line 7.

9. Functions like square are often generally referred to as overloaded functions in Haskell programming books and resources.

10. Ada gives the programmer the ability to suspend type checking.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.80.209