Learn English – the meaning of “falling off the end”

meaningmeaning-in-contextphrase-meaning

I am reading the book The C Programming Language. At the end of page 26 the paragraph that comes is,

A function need not return a value; a return statement with no expression causes control, but no useful value, to be returned to the caller, as does "falling off the end" of a function by reaching the terminating right brace.

What does "falling off the end" mean in the above written paragraph and also in general?

Best Answer

This is arguably a programming question and not an English question, but as it's ambiguous, I'll go ahead and answer. :-)

The idea is this: Suppose you were walking down a pier that sticks out into the water. You get to the end and try to keep walking. You will "fall off the end". That is, you have gotten to the end of the pier, and now you fall into the water.

In a function, normally there is a "return" statement to tell the compiler that it should end processing and return to the caller. If a function has no return statement, you get to the end of the function and, what is the compiler supposed to do? Instead of ending with a proper return statement, processing just "falls off the end". The statement you quote says that in that case the function will return, just as if you had ended it with a return statement.

Related Topic